Issue Bug Closed

#102346Variants on prioritizedCountries on CountrySelect form element show values which should be overwritten

Chris Müller 11/08/23, 09:13 updated 10/12/26, 19:18

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

  1. Josua Vogel commented <span data-processor="relativetime" data-value="2026-10-09T14:33:05+00:00" > 10/09/26, 14:33 </span>

    Properties set by a variant are merged into the existing ones, they do not replace them (AbstractFormElement::setProperty() uses ArrayUtility::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 prioritizedCountries the 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: __UNSET

    Simply replacing arrays instead of merging them would break the documented __UNSET removal 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.

  2. Josua Vogel commented and changed status Needs Feedback Closed <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.