Project

General

Profile

Actions

Bug #89204

closed

Form variants: Override ignored for arrays, if a value is removed

Added by Christian Eßl about 5 years ago. Updated almost 5 years ago.

Status:
Closed
Priority:
Should have
Category:
Form Framework
Start date:
2019-09-19
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
9
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:
Remote Sprint

Description

Take this SingleSelect as an example:

-
        properties:
          options:
            '': '---'
            mr: Mr.
            mrs: Mrs.
            miss: Miss
        defaultValue: ''
        type: SingleSelect
        identifier: salulation
        label: Salutation
        variants:
          -
            identifier: salulation-variant
            condition: 'siteLanguage("locale") == "zh_CN.utf-8"'
            properties:
              options:
                '': '---'
                mr: Mr.
                mrs: Mrs.

In case of the specified variant, a single option item shall be removed from the select. This will be ignored.

The reason is the following code in AbstractFormElement.php:

/**
     * Set a property of the element
     *
     * @param string $key
     * @param mixed $value
     */
    public function setProperty(string $key, $value)
    {
        if (is_array($value) && isset($this->properties[$key]) && is_array($this->properties[$key])) {
            ArrayUtility::mergeRecursiveWithOverrule($this->properties[$key], $value);
            $this->properties[$key] = ArrayUtility::removeNullValuesRecursive($this->properties[$key]);
        } elseif ($value === null) {
            unset($this->properties[$key]);
        } else {
            $this->properties[$key] = $value;
        }
    }

Overriding an array (in this case "options") will alway lead to an array_merge of the original and the new array. So as of now, you cannot remove an array item with the variants feature.

Actions #1

Updated by Gerrit Code Review about 5 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61764

Actions #2

Updated by Gerrit Code Review about 5 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61764

Actions #3

Updated by Christian Eßl about 5 years ago

  • Assignee set to Christian Eßl
Actions #4

Updated by Christian Eßl about 5 years ago

  • Target version set to Candidate for patchlevel
Actions #5

Updated by Susanne Moog about 5 years ago

  • Sprint Focus set to Remote Sprint
Actions #6

Updated by Gerrit Code Review almost 5 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61764

Actions #7

Updated by Gerrit Code Review almost 5 years ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61764

Actions #8

Updated by Gerrit Code Review almost 5 years ago

Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61764

Actions #9

Updated by Gerrit Code Review almost 5 years ago

Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61764

Actions #10

Updated by Gerrit Code Review almost 5 years ago

Patch set 1 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62288

Actions #11

Updated by Christian Eßl almost 5 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #12

Updated by Gerrit Code Review almost 5 years ago

  • Status changed from Resolved to Under Review

Patch set 2 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62288

Actions #13

Updated by Christian Eßl almost 5 years ago

  • Status changed from Under Review to Resolved
Actions #14

Updated by Benni Mack almost 5 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF