<p>I copied your markup, setting and name and label manually and it added the <code>disabled</code> property if I used <code>disabled: true</code></p>

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

<p><a href="https://i.sstatic.net/GOaPu.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/GOaPu.png" alt="enter image description here"></a></p>

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

<p>If that fails, I suggest you <a href="https://craftcms.com/docs/config-settings#devMode" rel="nofollow noreferrer">enable dev mode</a> and then use <a href="http://twig.sensiolabs.org/doc/functions/dump.html" rel="nofollow noreferrer">twig's dump() function</a> to check that you don't have any errors and that the field is given correct values.</p>

<p>Is there anything in your log file?</p>

CC BY-SA 3.0
2016-05-31T09:58:35.280Z
2016-05-31T09:58:35.280Z
Alexander Holsgrove
<p>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.</p>

<p>The problem that is occurring is that disabled class is added to the input but the disabled attribute is not.</p>

<p>This is what I've got:</p>

<pre><code>{% 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 %}
</code></pre>

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

<p>This is the HTML that I see when I inspect the element:</p>

<pre><code>&lt;input class="text disabled fullwidth" type="text" name="settings[abcd]" value="abc" autocomplete="off"&gt;
</code></pre>

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

CC BY-SA 3.0
2016-04-28T12:03:40.477Z
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`
Luke Pearce
<plugin-development><form>
Form input not being disabled
# Form input not being disabled

(Asked by: username_0 on 2016-03-09)

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:


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

**Tags:** plugin-development, form

> **Comments:**
> **username_1**: 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`  

---

## 1 answers

### Answer by username_2 on 2016-05-31. Score: 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
}) }}


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?


---

