function countries_field_widget_form in Countries 7
Same name and namespace in other branches
- 8 countries.fields.inc \countries_field_widget_form()
- 7.2 countries.fields.inc \countries_field_widget_form()
Implements hook_field_widget_form().
File
- ./
countries.module, line 546
Code
function countries_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
$default_value = array();
if (!is_array($items)) {
$items = array_filter(array(
$items,
));
}
foreach ($items as $item) {
$default_value[] = $item['iso2'];
}
$settings = $instance['widget']['settings'];
$filters = array(
'continents' => array_filter($settings['continents']),
'enabled' => $settings['enabled'],
);
$element += array(
'#type' => 'country',
'#default_value' => $default_value,
'#multiple' => $field['cardinality'] != 1,
'#cardinality' => $field['cardinality'],
'#size' => $field['cardinality'] != 1 ? $settings['size'] : 1,
'#filters' => $filters,
'#element_validate' => array(
'countries_country_field_validate',
'countries_country_element_validate',
),
);
return $element;
}