{"id":695,"date":"2019-11-28T06:29:13","date_gmt":"2019-11-28T06:29:13","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/2019\/11\/28\/create-input-tag-with-disabled-attribute-in-magento-system-xml\/"},"modified":"2025-05-22T15:21:23","modified_gmt":"2025-05-22T09:51:23","slug":"create-input-tag-with-disabled-attribute-in-magento-system-xml","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/create-input-tag-with-disabled-attribute-in-magento-system-xml\/","title":{"rendered":"How To Create Input Tag With Disabled Attribute In Magento system.xml"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">If you are someone who develops <a href=\"https:\/\/meetanshi.com\/magento-extensions.html\" target=\"_blank\" rel=\"noreferrer noopener\">Magento extensions<\/a> for store admins or who deliver work to another developer, bookmarking this post might be of help!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The post gives the method to create input tag with disabled attribute in Magento system.xml.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, you are developing a module that requires an external API integration. You don&#8217;t want the user to change the API details from the backend even though he has the access to the admin panel and configuration of the extension.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In that case, you can simply disable the fields that you want not to be changed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Other examples where you can implement this solution is when you don&#8217;t want the user to change the password, selected countries that are allowed to use a specific feature, etc.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Disable the attribute in Magento system.xml to get the result as shown below:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2019\/11\/1_Disabled-field-in-Magento-admin-panel.png\" alt=\"How To Create Input Tag With Disabled Attribute In Magento system.xml\" class=\"wp-image-6931\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Method to Create Input Tag With Disabled Attribute in Magento system.xml:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Find if the field code in system.xml is as below:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;token translate=\"label\">\n    &lt;label>Auth Token&lt;\/label>\n    &lt;frontend_type>text&lt;\/frontend_type>\n    &lt;sort_order>10&lt;\/sort_order>\n    &lt;show_in_default>1&lt;\/show_in_default>\n    &lt;show_in_website>0&lt;\/show_in_website>\n    &lt;show_in_store>0&lt;\/show_in_store>\n&lt;\/token><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">and replace it with the below:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;token translate=\"label\">\n    &lt;label>Auth Token&lt;\/label>\n    &lt;frontend_type>text&lt;\/frontend_type>\n    &lt;frontend_model>Vendor_Extension_Block_Field_Disable&lt;\/frontend_model>\n    &lt;sort_order>10&lt;\/sort_order>\n    &lt;show_in_default>1&lt;\/show_in_default>\n    &lt;show_in_website>0&lt;\/show_in_website>\n    &lt;show_in_store>0&lt;\/show_in_store>\n&lt;\/token><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Create a new file <em><strong>Disable.php<\/strong><\/em> at <strong><strong>Vendor\\Extension\\Block\\Field<\/strong><\/strong> &nbsp;folder<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\nclass Vendor_Extension_Block_Field_Disable extends Mage_Adminhtml_Block_System_Config_Form_Field{\n    protected function _getElementHtml($element) {\n        $element->setDisabled('disabled');\n        return parent::_getElementHtml($element);\n    }\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Secure your configuration with the above code.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Do not forget to share the solution with fellow developers!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thanks.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you are someone who develops Magento extensions for store admins or who deliver work to another developer, bookmarking this post might be of help!&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-695","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/695","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=695"}],"version-history":[{"count":4,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/695\/revisions"}],"predecessor-version":[{"id":15178,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/695\/revisions\/15178"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=695"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=695"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=695"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}