Simple XML layout changes for fields

Where to make changes

Blocks are defined via numerous different XML layout files (so: layout handles). While it is possible to add all of your changes to a single loki_checkout.xml file, we recommended you to add your own

Changing the field label

Every field has its own label and form element. Most of the fields are based on EAV attributes of the entity customer_address. The field label is based on the label of the EAV attribute, but you can override this in XML layout:

File loki_checkout_block_shipping_address.xml:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:View/Layout:etc/page_configuration.xsd">
    <body>
        <referenceBlock name="loki.checkout.shipping-step.shipping-address.postcode">
            <arguments>
                <argument name="field_label" xsi:type="string">Surname</argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

Changing the placeholder text

The HTML attribute placeholder is added to the PHTML field template by using the ComponentViewModel method ( getPlaceholder()) which again borrows the value from the block argument (getPlaceholder()). This means that you can simply set the placeholder via the XML layout:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:View/Layout:etc/page_configuration.xsd">
<body>
    <referenceBlock name="loki.checkout.shipping-step.shipping-address.postcode">
        <arguments>
            <argument name="placeholder" xsi:type="string">Your postcode</argument>
        </arguments>
    </referenceBlock>
</body>
</page>

However, you might also want to override the getPlaceholder() method of the ComponentViewModel to allow for changing the behaviour.

Coming soon

Last modified: January 12, 2025