In my system.xml, i have a field tag as:

<field id="token" translate="label comment" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
      <label>Auth Token</label>

What is attribute i need add to field tag for disable input in Configuration ?


5 Answers 5


I think <frontend_model> works for you as like Magento1

<field id="recipient_email" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
    <label>Send Emails To</label>

and your frontend_model class should be

namespace YOUR_NAMESPACE\YOUR_MODULE\Block\System\Config\Form\Field;

use Magento\Framework\Data\Form\Element\AbstractElement;

class Disable extends \Magento\Config\Block\System\Config\Form\Field
    protected function _getElementHtml(AbstractElement $element)
        return $element->getElementHtml();

Keyur Shah's answer is correct but I found that it is not possible to copy the value of the disabled element. So instead of writing $element->setDisabled('disabled'); you can write $element->setData('readonly', 1);. This displays the field the same way but you can mark the value and copy it.


This is not supported by current XSD of system.xml (Magento/Config/etc/system.xsd).

To enable such behavior for all types of fields at once it is possible to extend \Magento\Config\Block\System\Config\Form\Field::render() (e.g. using plugins) to make it support new type value of attribute element:

<field id="token" ...>
      <label>Auth Token</label>
      <attribute type="disabled">1</attribute>

At the moment it is possible to specify any value for type of attribute element, but only value shared will be processed, see \Magento\Config\Block\System\Config\Form::_getSharedCssClass(). Similar processing can be added in a new plugin to disable element if such attribute is specified.


another way to disable your field, is to set the value in the env.php file. The env.php allows you to set your configuration by default and disable the fields which are mapped in the env.php file. Your configuration could not be change by admin user. It's quite convenient if you want to put some sensitive settings.

'system' => [
   'default' => [
      'your_path => [
         'to_your' =>[
            'system_config =>['my special config in the store config']

Try set all show* fields to 0

<field id="token" showInDefault="0" showInWebsite="0" showInStore="0">
  • 1
    I want input tag disable, but if set attribute as you, it will hide
    – LinoPham
    Nov 19, 2015 at 20:38
  • agree with @ThaoPham Feb 4, 2020 at 14:45
  • @ThaoPham is correct Aug 14, 2020 at 13:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.