In this post I am going to explain how to add readonly field in ui_component form in Magento 2.
Check the below example code snippet to add readonly field in ui_component.
<field name="identifier" formElement="hidden">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="dataType" xsi:type="string">text</item>
<item name="label" xsi:type="string" translate="true">Identifier</item>
<item name="formElement" xsi:type="string">input</item>
<item name="source" xsi:type="string">identifier</item>
<item name="dataScope" xsi:type="string">identifier</item>
</item>
</argument>
<settings>
<dataType>text</dataType>
<disabled>1</disabled>
</settings>
</field>Here under “<settings>” tag “<disabled>1</disabled>” tag is used to make field readonly.
Thats it. Enjoy Magento 2!!
Write an article about ecommerce that help people to grow their ecommerce business. You’ll find best ecommerce guide, news, tips & more!



Leave a Reply