Révision fbb05e21
Ajouté par Assos Assos il y a environ 9 ans
drupal7/sites/all/modules/addressfield/addressfield.module | ||
---|---|---|
298 | 298 |
function theme_addressfield_container($variables) { |
299 | 299 |
$element = $variables['element']; |
300 | 300 |
$element['#children'] = trim($element['#children']); |
301 |
// Remove the autocomplete attributes because the W3C validator complains.
|
|
302 |
// They are only used on forms anyway.
|
|
301 |
// Remove the autocomplete attribute because the W3C validator complains. |
|
302 |
// It's only used on forms anyway.
|
|
303 | 303 |
unset($element['#attributes']['autocomplete']); |
304 |
unset($element['#attributes']['x-autocompletetype']); |
|
305 | 304 |
|
306 | 305 |
if (strlen($element['#children']) > 0) { |
307 | 306 |
$output = '<' . $element['#tag'] . drupal_attributes($element['#attributes']) . '>'; |
... | ... | |
375 | 374 |
function addressfield_default_values($field, $instance, array $address = array()) { |
376 | 375 |
$available_countries = _addressfield_country_options_list($field, $instance); |
377 | 376 |
$default_country = $instance['widget']['settings']['default_country']; |
378 |
// If the default country is not in the list of available countries, |
|
379 |
// fallback to the first country in the list. |
|
380 |
if ($default_country && !isset($available_countries[$default_country])) { |
|
377 |
// Resolve the special site_default option. |
|
378 |
if ($default_country == 'site_default') { |
|
379 |
$default_country = variable_get('site_default_country', ''); |
|
380 |
} |
|
381 |
// Fallback to the first country in the list if the default country is not |
|
382 |
// available, or is empty even though the field is required. |
|
383 |
$not_available = $default_country && !isset($available_countries[$default_country]); |
|
384 |
$empty_but_required = empty($default_country) && !empty($instance['required']); |
|
385 |
if ($not_available || $empty_but_required) { |
|
381 | 386 |
$default_country = key($available_countries); |
382 | 387 |
} |
383 | 388 |
|
... | ... | |
458 | 463 |
'field types' => array('addressfield'), |
459 | 464 |
'settings' => array( |
460 | 465 |
'available_countries' => array(), |
461 |
'default_country' => '', |
|
466 |
// Can't use variable_get('site_default_country') here because it would |
|
467 |
// set the value in stone. Instead, the site_default option allows the |
|
468 |
// default country to always reflect the current site setting. |
|
469 |
'default_country' => 'site_default', |
|
462 | 470 |
'format_handlers' => array('address'), |
463 | 471 |
), |
464 | 472 |
); |
... | ... | |
487 | 495 |
$form['default_country'] = array( |
488 | 496 |
'#type' => 'select', |
489 | 497 |
'#title' => t('Default country'), |
490 |
'#options' => _addressfield_country_options_list(), |
|
498 |
'#options' => array('site_default' => t('- Site default -')) + _addressfield_country_options_list(),
|
|
491 | 499 |
'#default_value' => $settings['default_country'], |
492 | 500 |
'#empty_value' => '', |
493 | 501 |
); |
Formats disponibles : Unified diff
Weekly update of contrib modules