Commit 20e725de authored by dww's avatar dww Committed by bojanz
Browse files

Issue #2889734 by dww, lukedekker, bojanz: Incorrect Ajax substitution for predefined subdivisions

parent 49602451
......@@ -334,8 +334,15 @@ class Address extends FormElement {
* Ajax callback.
*/
public static function ajaxRefresh(array $form, FormStateInterface $form_state) {
$country_element = $form_state->getTriggeringElement();
$address_element = NestedArray::getValue($form, array_slice($country_element['#array_parents'], 0, -2));
$triggering_element = $form_state->getTriggeringElement();
$parents = $triggering_element['#array_parents'];
$triggering_element_name = array_pop($parents);
// The country_code element is nested one level deeper than
// the subdivision elements.
if ($triggering_element_name == 'country_code') {
array_pop($parents);
};
$address_element = NestedArray::getValue($form, $parents);
return $address_element;
}
......
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