Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
address
Commits
e3ea8a9d
Commit
e3ea8a9d
authored
Jul 01, 2017
by
Bojan Živanović
Browse files
Issue
#2891564
by bojanz: Address::clearValues doesn't run for subdivision elements
parent
20e725de
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/Element/Address.php
View file @
e3ea8a9d
...
...
@@ -348,7 +348,7 @@ class Address extends FormElement {
}
/**
* Clears
the country-specific
form values when the country changes.
* Clears
dependent
form values when the country
or subdivision
changes.
*
* Implemented as an #after_build callback because #after_build runs before
* validation, allowing the values to be cleared early enough to prevent the
...
...
@@ -360,14 +360,22 @@ class Address extends FormElement {
return
$element
;
}
$triggering_element_name
=
end
(
$triggering_element
[
'#parents'
]);
if
(
$triggering_element_name
==
'country_code'
)
{
$keys
=
[
$keys
=
[
'country_code'
=>
[
'dependent_locality'
,
'locality'
,
'administrative_area'
,
'postal_code'
,
'sorting_code'
,
];
],
'administrative_area'
=>
[
'dependent_locality'
,
'locality'
,
],
'locality'
=>
[
'dependent_locality'
,
],
];
$triggering_element_name
=
end
(
$triggering_element
[
'#parents'
]);
if
(
isset
(
$keys
[
$triggering_element_name
]))
{
$input
=
&
$form_state
->
getUserInput
();
foreach
(
$keys
as
$key
)
{
foreach
(
$keys
[
$triggering_element_name
]
as
$key
)
{
$parents
=
array_merge
(
$element
[
'#parents'
],
[
$key
]);
NestedArray
::
setValue
(
$input
,
$parents
,
''
);
$element
[
$key
][
'#value'
]
=
''
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment