This has been plaguing me for weeks.

If a form API generated field has #type => 'textfield' and #disabled => TRUE, then it will not get submitted to _Validate() hook or _submit() hook.

Why?

And furthermore, why is #type => 'select' / 'checkbox' etc, being submitted while disabled?

What is going on here?

How do I make it so textfields are sent even if disabled??

Displaying the $form_state on validate() (or tamper data plugin for firefox) shows that there is no POST data being submitted.

Causing huge problems if a form field is dynamically disabled, then it thinks it is empty when it is not.

Comments

jaypan’s picture

This is an HTTP limitation, not Drupal.

Contact me to contract me for D7 -> D10/11 migrations.

jrockowitz’s picture

and set the input's background to gray. I am not 100% this works with checkboxes. Also you could use a little jQuery to disable inputs but still submit them using with a plugin like http://plugins.jquery.com/project/readonly.

executex’s picture

So what would be the work around for ensuring either disabled fields get submitted, or using $form_state to save the fields properly?

EDIT:
Here's my solution: Just requery all the fields after a submit() handle. Use $form_state to bring back the new database query since AHAH API caches everything.