How To Create Input Tag With Disabled Attribute In Magento system.xml

How To Create Input Tag With Disabled Attribute In Magento system.xml

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!

The post gives the method to create input tag with disabled attribute in Magento system.xml.

For example, you are developing a module that requires an external API integration. You don’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.

In that case, you can simply disable the fields that you want not to be changed.

Other examples where you can implement this solution is when you don’t want the user to change the password, selected countries that are allowed to use a specific feature, etc.

Disable the attribute in Magento system.xml to get the result as shown below:

Create Input Tag With Disabled Attribute In Magento system.xml

Method to Create Input Tag With Disabled Attribute in Magento system.xml:

Find if the field code in system.xml is as below:

and replace it with the below:

Create a new file Disable.php at Vendor\Extension\Block\Field  folder

That’s it.

Secure your configuration with the above code.

Need further help on the topic? Please mention in the Comments section below. I’d be happy to help.

Do not forget to share the solution with fellow developers!

Thanks.

 

5
(based on 3 Reviews)

Sanjay is a co-founder at Meetanshi. He is a Certified Magento Developer who loves creating Magento E-commerce solutions. When he is not engrossed with anything related to Magento, he loves to play cricket.

Leave a Reply