Commit 89fbd985 authored by bojanz's avatar bojanz
Browse files

Issue #2908575 followup: Guard against incomplete , fix langcode notice.

parent 034924a2
......@@ -104,7 +104,7 @@ class Address extends FormElement {
public static function valueCallback(&$element, $input, FormStateInterface $form_state) {
// Ensure both the default value and the input have all keys set.
// Preselect the default country to ensure it's present in the value.
if (is_array($input)) {
if (!empty($input['country_code'])) {
$input = self::applyDefaults($input);
}
$element['#default_value'] = (array) $element['#default_value'];
......@@ -113,7 +113,7 @@ class Address extends FormElement {
$element['#default_value']['country_code'] = Country::getDefaultCountry($element['#available_countries']);
}
return is_array($input) ? $input : $element['#default_value'];
return !empty($input['country_code']) ? $input : $element['#default_value'];
}
/**
......@@ -150,7 +150,7 @@ class Address extends FormElement {
] + $element;
$element['langcode'] = [
'#type' => 'hidden',
'#value' => $value['langcode'],
'#value' => $element['#default_value']['langcode'],
];
$element['country_code'] = [
'#type' => 'address_country',
......
......@@ -91,7 +91,7 @@ class ZoneTerritory extends FormElement {
public static function valueCallback(&$element, $input, FormStateInterface $form_state) {
// Ensure both the default value and the input have all keys set.
// Preselect the default country to ensure it's present in the value.
if (is_array($input)) {
if (!empty($input['country_code'])) {
$input = self::applyDefaults($input);
}
$element['#default_value'] = (array) $element['#default_value'];
......@@ -100,7 +100,7 @@ class ZoneTerritory extends FormElement {
$element['#default_value']['country_code'] = Country::getDefaultCountry($element['#available_countries']);
}
return is_array($input) ? $input : $element['#default_value'];
return !empty($input['country_code']) ? $input : $element['#default_value'];
}
/**
......
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