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

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

In the previous blog, I posted the solution to create input tag with disabled attribute in Magento system.xml

This solution is supposed to be implemented when you want to restrict the admin to change the values of particular fields for the proper working of your Magento 2 extensions.

Again, I’ve come up with a similar solution but for Magento 2.

Create input tag with disabled attribute in Magento 2 system.xml and restrict the admin users from changing the values of fields like passwords, API integration key and its details, etc.

Method To Create Input Tag With Disabled Attribute In Magento 2 system.xml:

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

and replace it with below code:

Create a new file Disable.php at Vendor\Extension\Block\System\Config\Form  folder

That was all.

Do not let any user play with your configuration! Give them access to only the selected fields. Disable the rest of them with the above solution.

The readers may use the Comments section below to post any questions regarding the above implementation. I’d be happy to help.

Do share the solution with fellow developers via social media.

Thank you!

 

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