Bug #96424
closedResetting form validators does not work as expected
100%
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:
- Current code: https://3v4l.org/8Bnd3 (fails)
- Variant with
clone
: https://3v4l.org/imCXv (works)
Updated by Gerrit Code Review almost 3 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
Updated by Gerrit Code Review almost 3 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
Updated by Gerrit Code Review almost 3 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
Updated by Gerrit Code Review over 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
Updated by Gerrit Code Review over 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
Updated by Gerrit Code Review over 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
Updated by Gerrit Code Review over 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
Updated by Gerrit Code Review over 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
Updated by Anonymous over 2 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 6f8007a805ba8692ac98dc35780a1821bbab67ea.
Updated by Gerrit Code Review over 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
Updated by Helmut Hummel over 2 years ago
- Has duplicate Bug #97028: Validators not removed when variant applies added
Updated by Anonymous over 2 years ago
- Status changed from Under Review to Resolved
Applied in changeset 3d8c8f034efacce6e3e7315cb99e1a41f921efa7.
Updated by Gerrit Code Review over 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
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/+/73707
Updated by Helmut Hummel over 2 years ago
- Status changed from Under Review to Resolved
Applied in changeset ac1887b3067a877cece583b91fa74f7ac7050cde.
Updated by Gerrit Code Review over 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
Updated by Gerrit Code Review over 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
Updated by Gerrit Code Review over 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
Updated by Helmut Hummel over 2 years ago
- Status changed from Under Review to Resolved
Applied in changeset 3e0971218cab220837a079877d8a5216350ac1af.