{"id":11964,"date":"2021-01-28T13:36:12","date_gmt":"2021-01-28T08:06:12","guid":{"rendered":"https:\/\/www.hiddentechies.com\/blog\/?p=11964"},"modified":"2021-01-29T14:01:48","modified_gmt":"2021-01-29T08:31:48","slug":"readonly-field-ui-component-form-magento-2","status":"publish","type":"post","link":"https:\/\/www.hiddentechies.com\/blog\/magento\/readonly-field-ui-component-form-magento-2\/","title":{"rendered":"How to Add Readonly Field in ui_component Form in Magento 2"},"content":{"rendered":"<p>In this post I am going to explain how to add readonly field in ui_component form in Magento 2.<\/p>\n<p>Check the below example code snippet to add <strong>readonly<\/strong> field in <strong>ui_component<\/strong>.<\/p>\n<pre class=\"lang:default decode:true \">&lt;field name=\"identifier\" formElement=\"hidden\"&gt;\r\n    &lt;argument name=\"data\" xsi:type=\"array\"&gt;\r\n        &lt;item name=\"config\" xsi:type=\"array\"&gt;\r\n            &lt;item name=\"dataType\" xsi:type=\"string\"&gt;text&lt;\/item&gt;\r\n            &lt;item name=\"label\" xsi:type=\"string\" translate=\"true\"&gt;Identifier&lt;\/item&gt;\r\n            &lt;item name=\"formElement\" xsi:type=\"string\"&gt;input&lt;\/item&gt;\r\n            &lt;item name=\"source\" xsi:type=\"string\"&gt;identifier&lt;\/item&gt;\r\n            &lt;item name=\"dataScope\" xsi:type=\"string\"&gt;identifier&lt;\/item&gt;\r\n        &lt;\/item&gt;\r\n    &lt;\/argument&gt;\r\n    &lt;settings&gt;\r\n        &lt;dataType&gt;text&lt;\/dataType&gt;\r\n        &lt;disabled&gt;1&lt;\/disabled&gt;\r\n    &lt;\/settings&gt;\r\n&lt;\/field&gt;<\/pre>\n<p>Here under <strong>&#8220;&lt;settings&gt;&#8221; tag &#8220;&lt;disabled&gt;1&lt;\/disabled&gt;&#8221;<\/strong> tag is used to make field <strong>readonly<\/strong>.<\/p>\n<p>Thats it. Enjoy Magento 2!!<\/p>\n<div class=\"angwp_12010 _ning_cont _ning_hidden _ning_outer _align_center responsive\" data-size=\"custom\" data-bid=\"12010\" data-aid=\"0\" style=\"max-width:800px; width:100%;height:inherit;\"><div class=\"_ning_label _left\" style=\"\"><\/div><div class=\"_ning_inner\" style=\"\"><a href=\"https:\/\/www.hiddentechies.com\/blog?_dnlink=12010&t=1775803577\" class=\"strack_cli _ning_link\" target=\"_blank\">&nbsp;<\/a><div class=\"_ning_elmt\"><img decoding=\"async\" src=\"https:\/\/www.hiddentechies.com\/blog\/wp-content\/uploads\/angwp\/items\/12010\/Banner-2.png\" \/><\/div><\/div><\/div><div class=\"clear\"><\/div>","protected":false},"excerpt":{"rendered":"<p>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. &lt;field name=&#8221;identifier&#8221; formElement=&#8221;hidden&#8221;&gt; &lt;argument name=&#8221;data&#8221; xsi:type=&#8221;array&#8221;&gt; &lt;item name=&#8221;config&#8221; xsi:type=&#8221;array&#8221;&gt; &lt;item name=&#8221;dataType&#8221; xsi:type=&#8221;string&#8221;&gt;text&lt;\/item&gt; &lt;item name=&#8221;label&#8221; xsi:type=&#8221;string&#8221; translate=&#8221;true&#8221;&gt;Identifier&lt;\/item&gt; &lt;item name=&#8221;formElement&#8221; xsi:type=&#8221;string&#8221;&gt;input&lt;\/item&gt; &lt;item name=&#8221;source&#8221; xsi:type=&#8221;string&#8221;&gt;identifier&lt;\/item&gt; &lt;item name=&#8221;dataScope&#8221;&#8230; <\/p>\n<div class=\"actions\"><a href=\"https:\/\/www.hiddentechies.com\/blog\/magento\/readonly-field-ui-component-form-magento-2\/\">Continue Reading<\/a><\/div>\n","protected":false},"author":1,"featured_media":12270,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[181,59,2138],"tags":[729,9,10,2153],"_links":{"self":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts\/11964"}],"collection":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/comments?post=11964"}],"version-history":[{"count":2,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts\/11964\/revisions"}],"predecessor-version":[{"id":12318,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts\/11964\/revisions\/12318"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/media\/12270"}],"wp:attachment":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/media?parent=11964"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/categories?post=11964"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/tags?post=11964"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}