In the plugin I'm creating I've got a form that has inputs which are set as disabled if they are overridden in a conifg file.

The problem that is occurring is that disabled class is added to the input but the disabled attribute is not.

This is what I've got:

{% import "_includes/forms" as forms %}    
{% set configSettings = craft.config.get('settings', 'myPlugin') %}
{% for paramKey, paramValue in array %}
       {% set disabled = (configSettings[paramKey] is defined) %}
       {# other variable sets here #}
       {{ forms.textField({
            label: paramLabel,
            name: inputName,
            value : paramValue,
            disabled: disabled,
            required: required
            }) }}

{% endfor %}

When I navigate to the page, the input field is greyed out but I can still input data to the input field.

This is the HTML that I see when I inspect the element:

<input class="text disabled fullwidth" type="text" name="settings[abcd]" value="abc" autocomplete="off">

I tried disabled: true and disabled: 1 in the code above to test and the same html is returned.

  • 3
    Just had a look in the files that make up the text fields and see this line {%- if disabled is defined and disabled %} disabled {% endif %} meaning a boolean value should work. I found it in /craft/app/templates/_includes/forms/text.html Commented Apr 28, 2016 at 12:03

1 Answer 1


I copied your markup, setting and name and label manually and it added the disabled property if I used disabled: true

{{ forms.textField({
label: 'Example Label',
name: 'Example Name',
value : 'Example Value',
disabled: true,
required: true
}) }}

enter image description here

Perhaps you could try manually defining the field (as I did) without reading from the variables and confirm that it works.

If that fails, I suggest you enable dev mode and then use twig's dump() function to check that you don't have any errors and that the field is given correct values.

Is there anything in your log file?

Your Answer

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

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