Back to top

Modules related Blog Posts

Use Drupal Form API to disable one of the items in an #options array()
Swarad Mokal
By Swarad Mokal on 27 Jun 2016

For Drupal elements like checkboxes or radios we provide the options for these lists via a array which as per Drupal docs has to be a simple key value pair.

For the element checkboxes or radios, if you do #disabled, it will disable all the items from the options array(). 

What if you want to disable only one of the checkboxes or have a class on ony one of the radio element ?? Javascript ? or a crude element_process() ?

There is actually a a very neat and clean way (and largely undocumented it seems),