diff --git a/addressfield.module b/addressfield.module index 68b45d9..755aeb0 100644 --- a/addressfield.module +++ b/addressfield.module @@ -385,13 +385,6 @@ function addressfield_default_values($field, $instance, array $address = array() if ($default_country == 'site_default') { $default_country = variable_get('site_default_country', ''); } - // Fallback to the first country in the list if the default country is not - // available, or is empty even though the field is required. - $not_available = $default_country && !isset($available_countries[$default_country]); - $empty_but_required = empty($default_country) && !empty($instance['required']); - if ($not_available || $empty_but_required) { - $default_country = key($available_countries); - } $default_values = array( 'country' => $default_country, @@ -882,6 +875,7 @@ function _addressfield_country_options_list($field = NULL, $instance = NULL) { $countries = country_get_list(); } + $none_option = array(); if (isset($field)) { // If the instance is not specified, loop against all the instances of the field. if (!isset($instance)) { @@ -894,6 +888,9 @@ function _addressfield_country_options_list($field = NULL, $instance = NULL) { } else { $instances = array($instance); + if ($instance['required'] == 1) { + $none_option = array('' => t('- Select a value -')); + } } foreach ($instances as $instance) { @@ -904,5 +901,6 @@ function _addressfield_country_options_list($field = NULL, $instance = NULL) { } } + $countries = $none_option + $countries; return $countries; }