#102346Variants on prioritizedCountries on CountrySelect form element show values which should be overwritten
Description
When using the following configuration which defines a CountrySelect element in a form which uses variants to overwrite the prioritizedCountries for a given language:
renderables:
- properties:
fluidAdditionalAttributes:
required: required
autocomplete: country
prependOptionLabel: prependOptionLabel
prioritizedCountries:
- AU
- CA
- NZ
- GB
- US
type: CountrySelect
identifier: country
label: country
validators:
- identifier: NotEmpty
variants:
- identifier: country-pl
condition: 'siteLanguage("languageId") === 2'
properties:
prioritizedCountries:
- PL
I would expect for the Polish language (language ID = 2), that Poland is the only prioritized country (= visible at the top of the select box). However, the following countries are prioritized:
- PL
- CA
- NZ
- GB
- US
This is obviously wrong. I would expect only:
- PL
to be prioritized.
I tracked it down to the AbstractFormElement->setProperty() method, which receives as value ['PL'] and then ArrayUtility::mergeRecursiveWithOverrule() is called which just overrides the index “0”, but does not reset the prioritizedCountries property before.
Using TYPO3 v12.4.7.
Reviews 1
History 35
-
Gerrit Code Review pushed patch set 1 for main to change 92377 status
NewUnder Review <span data-processor="relativetime" data-value="2026-01-18T18:14:14+00:00" > 01/18/26, 18:14 </span> -
Gerrit Code Review pushed patch set 2 for main to change 92377 <span data-processor="relativetime" data-value="2026-01-18T18:15:27+00:00" > 01/18/26, 18:15 </span>
-
Josua Vogel changed status
Under ReviewNeeds Feedback <span data-processor="relativetime" data-value="2026-10-12T08:11:59+00:00" > 10/12/26, 08:11 </span> -
Josua Vogel commented and changed status
Needs FeedbackClosed <span data-processor="relativetime" data-value="2026-10-12T19:18:44+00:00" > 10/12/26, 19:18 </span>I am closing this ticket for the reasons mentioned above. If anyone thinks this is incorrect, they are welcome to create a new ticket based on my last comment.
Properties set by a variant are merged into the existing ones, they do not replace them (
AbstractFormElement::setProperty()usesArrayUtility::mergeRecursiveWithOverrule()). This is intentional: it lets a variant change or remove single entries, for example one select option (see “Remove select options” in the form documentation, Concepts > Variants).For a list like
prioritizedCountriesthe merge goes by index, so['PL']only overwrites index 0. The remaining entries can be removed explicitly with__UNSET:variants: - identifier: country-pl condition: 'siteLanguage("languageId") === 2' properties: prioritizedCountries: 0: PL 1: __UNSET 2: __UNSET 3: __UNSET 4: __UNSETSimply replacing arrays instead of merging them would break the documented
__UNSETremoval of single entries, so it cannot go into the LTS branches as a bugfix.A long-term rule could be “maps are merged, lists are replaced”, but that is a behaviour change. I would like to close this issue.