1

I just need to set a default value (with readonly attribute) to the city field in the shipping address section. because the delivery is limited to a particular city at the moment.But the user is free to type any city name in billing address.

In the LayoutProcessor, getBillingAddressComponent() method i have added :

....

....

.... 

'city' => [
    'readonly' =>'readonly',
    'config' => [
    'value' =>'My Custom Value',
    'readonly' =>'readonly',
     'elementTmpl' => 'ui/form/element/textC',
        'tooltip' => [
            'description' => __('We deliver items only in selected cities at the moment.'),
        ],
    ],
],

....

....

TextC.html

<input class="admin__control-text" type="text" value="My Custom Value" readonly
data-bind="
    value: value,
    hasFocus: focused,
    valueUpdate: valueUpdate,
    attr: {
        name: inputName,
        placeholder: placeholder,
        'aria-describedby': noticeId,
        id: uid,
        disabled: disabled,
        maxlength: 255
        readonly: readonly
}"/>

Mean time i don't care about editing the core files. Iam working in Magento 2.2

Iam familiar with copying and editing templates in magento 1.X. But i can't find a way to achieve this in Magento 2. Im not sure that im in a right path.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.