According to hook_form_alter doc for webform, I can target the component's properties using $form['submitted']['component_name'], etc. This works fine for altering title, weight, description. The form structure of webform looks something like:

  [#tree] => 1
  [component_email] => Array
       [#type] => webform_email
       [#title] => Email
       [#webform_component] => Array
           [extra] => Array
             [disabled] => 0

Simply changing the disabled property to true or 1 doesn't disabled the component. I have also tried the $form['#node']->webform path.

1 Answer 1


I have never had luck trying to set the disabled flag via a FormsAPI hook using the array indexes. Looking at the code above, it would also seem that you are setting the incorrect 'disabled' for the form array - #disabled is what is checked during the rendering process.

But, like I said, never had much luck with it anyway. What you may end up needing to do is set the #attributes array for the form element, specifically identifying the disabled property as in the html element tag:

<input type='text' disabled />
// becomes
$form['element']['#attributes'] = array('disabled' => '1');

obviously with the form indexes specified as needed.

  • Thank you sir! $form['submitted']['component_name']['#attributes']['disabled'] = true did the trick
    – rwaery
    Jan 23, 2014 at 17:46

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.