As I see the checkbox elements' customization possibility is undocumented in form API reference. To be more specific take a look to the following example:

$form['myboxes'] = array(
  '#type' => 'checkboxes',
  '#options' => array(
    'foo' => t('Foo'),
    'bar' => t('Bar'),
    'baz' => t('Baz'),
  ),
);

$form['myboxes']['foo'] = array(
  '#attributes' => array('class' => array('ok')),
);
$form['myboxes']['bar'] = array(
  '#disabled' => TRUE,
);

The above snippet is from here and it actually works I tested it. However if I'am not wrong it is still not documented.

Please document the above mentioned behavior on the Form API Reference page.

Comments

balazswmann’s picture

Component: forms system » documentation
jhodgdon’s picture

Project: Drupal core » Documentation
Version: 7.x-dev »
Component: documentation » API documentation files
Status: Active » Closed (works as designed)
Issue tags: +FAPI reference

The #default, #options, and #attributes properties are all actually documented. You just have to click on the links at the top of the checkboxes section. I don't think there is any missing documentation. Please open this issue back up if you think there is.

Also I've moved this to the Documentation project because the file for that page is in that repository, not in Core.

balazswmann’s picture

Status: Closed (works as designed) » Active

Thanks for the project related changes, however I still think that the mentioned behavior of the checkboxes form element is not documented.

That is correct that attributes (like #default_value, #options, #attributes, etc.) are documented both at the checkbox element and at the checkboxes element, but if you are using the checkboxes element it is not documented how you can customize the attributes of it's checkbox elements. You can specify each checkbox element's key and value in the checkboxes element's #options property as you can read in the checkboxes element's description section, but you are not informed about how you can customize other checkbox properties apart from their key and value. So this is what I wanted to point out since this is a really important behavior. Without this information developers are not able to customize checkbox elements' properties inside a checkboxes form element, or they have to use different "dirty tricks" (like #process, #after_build, etc..) to accomplish the same behavior meanwhile there is this "simple and clean" but undocumented solution.

jhodgdon’s picture

Ah, OK. Thanks for writing down what you think needs to be documented. Sounds like a reasonable thing to document. I didn't understand what you were talking about from your original issue report.

jhodgdon’s picture

Status: Active » Closed (duplicate)