Comboselect element

The comboselect element has not yet been included in Elements. You can follow its development at #268424.

The comboselect written by John Morahan gives you a select type element with an 'Other' option. When the user chooses this option; a textfield appears.

Create a simple comboselect element

function example_elements_form() {
$form = array();

$options = array(
'one' => t('First Option'),
'two' => t('Second Option'),
);

$form['choice'] = array(
'#type' => 'comboselect',
'#title' => t('Example'),
'#default_options' => $options,
);

$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);

return $form;
}


Change the 'Other' option

function example_elements_form() {
$form = array();

$options = array(
'one' => t('First Option'),
'two' => t('Second Option'),
);

$form['test'] = array(
'#type' => 'comboselect',
'#title' => t('Example'),
'#required' => TRUE,
'#default_options' => $options,
'#other' => t('None of the above, but'),
);

$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);

return $form;
}

AttachmentSize
comboselect_other_wording.JPG15.45 KB