I have a case where I use hook_form_alter() to force a default value on a '#type' => radios field. That part is working. But then I'd also like to disable the field so that the users cannot override the choice. That does not work at any level of the form element array.

Looking at theme_radios(), it seems that #disabled is not allowed (I have no idea why). But the Forms API Reference indicates that it should be allowed.

Comments

vimalgoradiya’s picture

I already tried lot time for disable the radios and it works fine. Within form alter I try using $form['field_audience']['#disabled'] = TRUE; and it work like charm.

cilefen’s picture

@NancyDru May we see your code?

nancydru’s picture

Status: Active » Closed (works as designed)

I was actually doing it following a drupal_get_form(). Moving the code into an actual hook_form_alter() worked correctly.