It is possible to pass value from XML to JS components.

 <field name="postcode" component="Magento_Ui/js/form/element/post-code" formElement="input" sortOrder="70">
                <label translate="true">Zip/Postal Code</label>
                    <rule name="required-entry" xsi:type="boolean">true</rule>

For example here we can pass the label. In our case Zip/Postal Code.

I wish to pass a custom field value

For e.g.

   <custom_field>Custom Value</custom_field>

Also tried by passing it as an attribute for the field node as such

<field custom_field="Custom Value" ....

with no luck. The value is not available in the JS component (in this example Magento_Ui/js/form/element/post-code)

Any ideas on how to achieve this?

1 Answer 1


Try this:

<field name="postcode" component="Magento_Ui/js/form/element/post-code" formElement="input" sortOrder="70">
    <argument name="data" xsi:type="array">
        <item name="config" xsi:type="array">
            <item name="custom_field" xsi:type="string">Custom Value</item>
            <!-- here you can add anything you need without restrictions -->

but you also might need to create your own component in order to be able to use the custom value, or extend the original component.

  • This indeed works. But it duplicates the value for all fields that use that component (thus making redundant the whole thing in my case). If we have two postcode fields on the same page that use the same component (shipping and billing) both will have the same value (the one that loads last). Any other ideas? Commented Jan 28, 2020 at 11:49
  • not sure I understand. Each component should be a separate instance. if you send different custom field values they should be handled separately.
    – Marius
    Commented Jan 28, 2020 at 13:43
  • It's treated like a singleton. The last configured value applies. Commented Jan 29, 2020 at 6:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.