By chaldar on
How does one disable some (but not all) options in checkboxes or radios?
I need this in some form_alter hooks where the idea is to selectively disable one or more options in a checkboxes or radios item dependent upon the current user. The disabled options remain visible but cannot be selected.
Comments
...
See http://drupal.org/node/244232 (which talks about '#attributes', but it's the same for '#disabled'.)
Thanks
Great! Thanks a lot.
#disabled in #after_build
For drupal6.17, I tried this. However, I found that I needed to set ['#attributes']['disabled'] instead of just ['#disabled'] to get any change.
My example #after_build function:
...
D6 has a bug with disabled fields. Unless your checkboxes are all off, you probably want to not disable them (Or just try it and see if it works; some fields work correctly nevertheless).