I am creating a custom field for phone numbers. The field creates a phone record that contains the type of phone contact (work, home, etc), as well as the number and an extension... much like Apple's "Contacts" app.
The problem I am having is for the phone type drop-down list. Instead of showing a nice drop-down select list like this example of a publishing status...
I end up with a selection box like this...
Here is what my hook_field_widget_info() looks like...
/**
* Implements hook_field_widget_form().
*/
function MYMODULE_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
$element['label'] = array(
'#type' => 'select',
'#options' => drupal_map_assoc(array(
t('home'),
t('work'),
t('main'),
t('mobile'),
t('other'),
)),
'#size' => 12,
'#default_value' => isset($items[$delta]['label']) ? $items[$delta]['label'] : 'home',
);
$element['number'] = array(
'#type' => 'textfield',
'#title' => t('Number'),
'#size' => 16,
'#default_value' => isset($items[$delta]['number']) ? $items[$delta]['number'] : '',
);
$element['ext'] = array(
'#type' => 'textfield',
'#field_prefix' => t('ext'),
'#size' => 6,
'#default_value' => isset($items[$delta]['ext']) ? $items[$delta]['ext'] : '',
);
$element['primary'] = array(
'#type' => 'ckeckbox',
'#default_value' => isset($items[$delta]['primary']) ? $items[$delta]['primary'] : 0,
'#return_value' => 1,
);
return $element;
}
I can see how the selection box style select element can be useful for multiple selects, but this is just a single select. I'd like to see a drop-down element. I must be missing something here, but I haven't figured out what it could be. Any ideas?