Project

General

Profile

Actions

Bug #96424

closed

Resetting form validators does not work as expected

Added by Elias Häußler over 2 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Form Framework
Target version:
-
Start date:
2021-12-21
Due date:
% Done:

100%

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

Description

Problem

If form validators are to be reset by calling \TYPO3\CMS\Form\Domain\Model\Renderable\AbstractRenderable::setOptions() with second parameter $resetValidators = false, it seems that not all validators are actually reset if there is more than one validator defined. This is because the underlying SplObjectStorage does not operate as someone might expect in combination with foreach.

Steps to reproduce

Generate a basic form with an element and a variant such as follows:

- identifier: element-1
  type: Text
  # ...

- identifier: element-2
  type: Text
  # ...
  validators:
    - identifier: NotEmpty
    - identifier: EmailAddress
  variants:
    -
      identifier: variant-1
      condition: 'formValues["element-1"] == "some-value"'
      validators: []

Now in the Frontend, set the value of element 1 to some-value and submit the form. You should receive a validation error for element 2, even though all validators should be removed in this case.

Solution

A simple solution would be to clone the validators when iterating and performing detaches (as suggested here).

For this, compare the result of the underlying code:


Related issues 1 (0 open1 closed)

Has duplicate TYPO3 Core - Bug #97028: Validators not removed when variant appliesClosed2022-02-24

Actions
Actions #1

Updated by Gerrit Code Review over 2 years ago

  • Status changed from New to Under Review

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

Actions #2

Updated by Gerrit Code Review over 2 years ago

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

Actions #3

Updated by Gerrit Code Review over 2 years ago

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

Actions #4

Updated by Ralf Zimmermann about 2 years ago

  • Sprint Focus set to Remote Sprint
Actions #5

Updated by Gerrit Code Review about 2 years ago

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

Actions #6

Updated by Gerrit Code Review about 2 years ago

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

Actions #7

Updated by Gerrit Code Review about 2 years ago

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

Actions #8

Updated by Gerrit Code Review about 2 years ago

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

Actions #9

Updated by Gerrit Code Review about 2 years ago

Patch set 1 for branch 11.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/+/73657

Actions #10

Updated by Anonymous about 2 years ago

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

Updated by Gerrit Code Review about 2 years ago

  • Status changed from Resolved to Under Review

Patch set 2 for branch 11.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/+/73657

Actions #12

Updated by Helmut Hummel about 2 years ago

  • Has duplicate Bug #97028: Validators not removed when variant applies added
Actions #13

Updated by Anonymous about 2 years ago

  • Status changed from Under Review to Resolved
Actions #14

Updated by Gerrit Code Review about 2 years ago

  • Status changed from Resolved to Under Review

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

Actions #15

Updated by Gerrit Code Review about 2 years ago

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

Actions #16

Updated by Helmut Hummel about 2 years ago

  • Status changed from Under Review to Resolved
Actions #17

Updated by Gerrit Code Review about 2 years ago

  • Status changed from Resolved to Under Review

Patch set 1 for branch 11.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/+/73711

Actions #18

Updated by Gerrit Code Review about 2 years ago

Patch set 2 for branch 11.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/+/73711

Actions #19

Updated by Gerrit Code Review about 2 years ago

Patch set 3 for branch 11.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/+/73711

Actions #20

Updated by Helmut Hummel about 2 years ago

  • Status changed from Under Review to Resolved
Actions #21

Updated by Benni Mack over 1 year ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF