function _countries_country_expand in Countries 7.2
Same name and namespace in other branches
- 8 countries.elements.inc \_countries_country_expand()
Our process callback to expand the country FAPI element.
1 call to _countries_country_expand()
- countries_country_expand in ./
countries.module - Our process callback to expand the country FAPI element.
File
- ./
countries.elements.inc, line 88 - Defines all element related code for the countries module.
Code
function _countries_country_expand($element) {
if (empty($element['#options'])) {
if (empty($element['#filters'])) {
$element['#filters']['enabled'] = COUNTRIES_ENABLED;
}
$element['#options'] = countries_get_countries('name');
}
$element['#options'] = countries_filter($element['#options'], $element['#filters']);
// Allow other modules to update this list.
countries_invoke_additional_countries_alter($element['#options']);
// Ensure that this is set in case '#hide_empty' is used.
if (empty($element['#required']) && !isset($element['#empty_value'])) {
$element['#empty_value'] = '';
}
// Adds a hidden element style for support of the continent-country widget.
if (!empty($element['#hide_empty'])) {
// Only return the element if it's not empty.
$count = count($element['#options']);
if (!$count || $count == 1 && isset($element['#options'][$element['#empty_value']])) {
$element += array(
'#prefix' => '',
'#suffix' => '',
);
$element['#prefix'] .= '<div style="display: none;">';
$element['#suffix'] = '</div>' . $element['#suffix'];
}
}
return $element;
}