I have added custom drop down list into checkout shipping address like this:
$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']
['shippingAddress']['children']['shipping-address-fieldset']['children']['drop_down'] = [
'component' => 'Magento_Ui/js/form/element/select',
'config' => [
'customScope' => 'shippingAddress',
'template' => 'ui/form/field',
'elementTmpl' => 'ui/form/element/select',
'id' => 'drop-down',
],
'dataScope' => 'shippingAddress.drop_down',
'label' => 'Distrist',
'provider' => 'checkoutProvider',
'visible' => true,
'validation' => [],
'sortOrder' => 251,
'id' => 'drop-down',
'options' => [
[
'value' => '',
'label' => 'Please select'
],
[
'value' => '1',
'label' => 'One'
],
[
'value' => '2',
'label' => 'Two'
],
[
'value' => '3',
'label' => 'Three'
]
]
];
How can I get the value and data-title has been selected then set it in the city field?
Thank you!
Best Answer
I have resolved my problem like this:
Update class LayoutProcessor:
After that, I create new select file with structure we have defined above.
We can copy "select.js" file from vendor to our folder:
And then update the select.js like this
First thing, define the City and Postcode field:
And check if the District has changed, we will update value for City and Postcode: