Im trying to get a set of checkboxes produced via Drupal's form api to pass the WCAG AA accessibility standards, the problem i am facing is with regard to labels and for attributes.
For example i am returning the following form definition via a hook_block_view()
$form['tests_taken'] = array(
'#type' => 'checkboxes',
'#options' => drupal_map_assoc(array(t('SAT'), t('ACT'))),
'#title' => t('What standardized tests did you take?'),
'#attributes' => array(
'name' => 'example-checkboxes[]'
)
);
$form['tests_taken'] = form_process_checkboxes($form['tests_taken']);
dsm($form);
return $form;
This produces the following markup.
<div class="form-checkboxes"><div class="form-item form-type-checkbox">
<input name="example-checkboxes[]" type="checkbox" value="SAT" class="form-checkbox"> <label class="option">SAT </label>
</div>
<div class="form-item form-type-checkbox">
<input name="example-checkboxes[]" type="checkbox" value="ACT" class="form-checkbox"> <label class="option">ACT </label>
</div>
</div>
I need the markup to either have labels with 'for' attributes pointing to the input elements or wrap the input elements with the label tag.