function select_or_other_test_form in Select (or other) 7.2
Same name and namespace in other branches
- 6.2 select_or_other.module \select_or_other_test_form()
- 6 select_or_other.module \select_or_other_test_form()
Test function. to view, visit http://example.com/?q=select-or-other-test-form You must have the permission 'access administration pages'.
1 string reference to 'select_or_other_test_form'
- select_or_other_menu in ./
select_or_other.test_form.inc - Implements hook_menu().
File
- ./
select_or_other.test_form.inc, line 28 - The Select (or other) test form.
Code
function select_or_other_test_form($form, $form_state) {
$v =& $form_state['values'];
$form['my_field_1'] = array(
'#type' => 'select_or_other',
'#title' => t('My example Field'),
'#default_value' => $v['my_field_1'] ? $v['my_field_1'] : array(
'Another value',
'extra value',
),
'#options' => array(
'option1' => t('Option 1'),
'option2' => t('Option 2'),
'option3' => t('Option 3'),
),
'#other' => t('Other (please type with your fingers)'),
'#required' => TRUE,
'#multiple' => FALSE,
'#other_delimiter' => ', ',
// if this is FALSE only the last value will be used
'#other_unknown_defaults' => 'other',
// possible values 'append', 'ignore', 'other' (if other specified you can also override #other_delimiter).
'#description' => t("The description of this element."),
);
$form['fieldset'] = array(
'#type' => 'fieldset',
'#title' => t('Fieldset'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['fieldset']['my_field_2'] = array(
'#type' => 'select_or_other',
'#select_type' => 'checkboxes',
'#title' => t('My checkboxes example'),
'#default_value' => $v['my_field_2'] ? $v['my_field_2'] : array(
'Another value',
),
'#options' => array(
'option1' => t('Option 1'),
'option2' => t('Option 2'),
'option3' => t('Option 3'),
),
'#other' => t('Other (please type with your fingers)'),
'#required' => TRUE,
'#multiple' => TRUE,
// this should be ignored for checkboxes
'#other_delimiter' => ', ',
// if this is FALSE only the last value will be used
'#other_unknown_defaults' => 'append',
// possible values 'append', 'ignore', 'other' (if other specified you can also override #other_delimiter).
'#other_title' => t('Other'),
'#other_description' => t('Description of other field.'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}