I want to add a new field to my shipping address section on checkout page, I was able to achieve it by below code.
<item name="shippingAddress" xsi:type="array">
<item name="children" xsi:type="array">
<item name="shipping-address-fieldset" xsi:type="array">
<item name="children" xsi:type="array">
<item name="location" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/form/element/abstract</item>
<item name="label" xsi:type="string">Location</item>
<item name="provider" xsi:type="string">checkoutProvider</item>
<item name="visible" xsi:type="string">true</item>
<item name="sortOrder" xsi:type="string">200</item>
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">ui/form/field</item>
<item name="elementTmpl" xsi:type="string">ui/form/element/input</item>
<item name="tooltip" xsi:type="array">
<item name="description" xsi:type="string" translate="true">Search your location.</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
The field is added to shipping address form but the name
attribute is null. I need to set it as location but it always stays null. I have tried adding name
and inputName
attributes to xml but nothing seems to be working. Please check below as the html generated for my field.
<input class="input-text" type="text" data-bind="
value: value,
valueUpdate: 'keyup',
hasFocus: focused,
attr: {
name: inputName,
placeholder: placeholder,
'aria-describedby': getDescriptionId(),
'aria-required': required,
'aria-invalid': error() ? true : 'false',
id: uid,
disabled: disabled
}" name="" aria-invalid="false" id="YCYKNDR">
Do anyone have any idea how we can set name
attribute for input field on shipping address section?