Select (or other)
Provides a new Forms API element which is a select/radios/checkboxes element that has an 'other' option. When 'other' is selected a textfield appears for the user to provide a custom value.
This is for developers to use in form functions, there is no CCK/Profile etc... integration.
See this issue for a Webform integration patch.
Example usage:
<?php
$form['my_field'] = array(
'#type' => 'select_or_other',
'#title' => t('Choose an option'),
'#default_value' => array('value_1'),
'#options' => array(
'value_1' => t('One'),
'value_2' => t('Two'),
'value_3' => t('Three'),
),
'#other' => t('Other (please type a value)'), // Text to show as 'other' option
'#required' => TRUE,
'#multiple' => TRUE,
'#other_unknown_defaults' => 'other', // If the #default_value is not a valid choice in #options, what should we do? Possible values 'append', 'ignore', 'other' (if 'other' specified you can also override #other_delimiter).
'#other_delimiter' => ', ', // Delimiter string to delimit multiple 'other' values into the 'other' textfield. If this is FALSE only the last value will be used.
'#select_type' => 'select', // Defaults to 'select'. Can also be 'radios' or 'checkboxes'.
);
?>The #properties you give the element that are recognised as FAPI select properties will be automatically assigned to the Select element. Also any #properties assigned as #select_property or #other_property will be passed down to the corresponding form element.
Releases
| Official releases | Date | Size | Links | Status | |
|---|---|---|---|---|---|
| 6.x-1.4 | 2009-Oct-03 | 8.77 KB | Download · Release notes | Recommended for 6.x | |
| Development snapshots | Date | Size | Links | Status | |
|---|---|---|---|---|---|
| 6.x-1.x-dev | 2009-Oct-24 | 9.82 KB | Download · Release notes | Development snapshot | |
