Commit 714ad0fc authored by czigor's avatar czigor Committed by bojanz

Issue #2633972 by czigor: Required addressfield has a '- Select -' option

parent b7bc4792
......@@ -294,7 +294,6 @@ class AddressDefaultWidget extends WidgetBase implements ContainerFactoryPluginI
'#options' => $country_list,
'#default_value' => $country_code,
'#required' => $element['#required'],
'#empty_value' => '',
'#limit_validation_errors' => [],
'#ajax' => [
'callback' => [get_class($this), 'ajaxRefresh'],
......@@ -306,6 +305,9 @@ class AddressDefaultWidget extends WidgetBase implements ContainerFactoryPluginI
],
'#weight' => -100,
];
if (!$element['#required']) {
$element['country_code']['#empty_value'] = '';
}
}
if (!empty($country_code)) {
$element = $this->addressElements($element, $values);
......
......@@ -212,7 +212,7 @@ class AddressDefaultWidgetTest extends WebTestBase {
}, $countries);
$this->drupalPostForm($this->fieldConfigUrl, $edit, t('Save settings'));
// Acccess article's edit form and confirm the values are unchanged.
// Access the article's edit form and confirm the values are unchanged.
// 'US' should be in the list along with the available countries and should
// be selected.
$this->drupalGet('node/' . $node->id() . '/edit');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment