Wednesday, August 15, 2012

How to create checkboxes in Drupal form alter?

Description: Format a set of checkboxes. #options is an associative array, where the key is the #return_value of the checkbox and the value is displayed. The #options array cannot have a 0 key, as it would not be possible to discern checked and unchecked states.
 
<?php
$form
['high_school']['tests_taken'] = array(
  
'#type' => 'checkboxes',
  
'#options' => drupal_map_assoc(array(t('SAT'), t('ACT'))),
  
'#title' => t('What standardized tests did you take?'),
...
),
?>
 
 

No comments:

Post a Comment