Skip to content

Commit

Permalink
[BUGFIX] Skip validation of form fields in disabled containers
Browse files Browse the repository at this point in the history
Aside from being disabled itself, a form field can also be placed in a
container which is disabled statically or using variants. In either case
the field must not be validated since it is not rendered and thus cannot
be filled by the user.

Resolves: #102083
Releases: main, 12.4
Change-Id: I8f2bcd45d3563907bf5737628020ab8bf50a68bc
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/82004
Tested-by: core-ci <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
  • Loading branch information
mbrodala authored and lolli42 committed Nov 29, 2023
1 parent 8a36b63 commit 93eafd2
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion typo3/sysext/form/Classes/Domain/Runtime/FormRuntime.php
Expand Up @@ -49,6 +49,7 @@
use TYPO3\CMS\Form\Domain\Model\FormDefinition;
use TYPO3\CMS\Form\Domain\Model\FormElements\FormElementInterface;
use TYPO3\CMS\Form\Domain\Model\FormElements\Page;
use TYPO3\CMS\Form\Domain\Model\Renderable\RenderableInterface;
use TYPO3\CMS\Form\Domain\Model\Renderable\RootRenderableInterface;
use TYPO3\CMS\Form\Domain\Model\Renderable\VariableRenderableInterface;
use TYPO3\CMS\Form\Domain\Renderer\RendererInterface;
Expand Down Expand Up @@ -568,7 +569,7 @@ protected function mapAndValidatePage(Page $page): Result
}

foreach ($page->getElementsRecursively() as $element) {
if (!$element->isEnabled()) {
if (!$this->isRenderableEnabled($element)) {
continue;
}

Expand Down Expand Up @@ -1106,4 +1107,19 @@ protected function getTypoScriptFrontendController(): ?TypoScriptFrontendControl
{
return $GLOBALS['TSFE'] ?? null;
}

protected function isRenderableEnabled(RenderableInterface $renderable): bool
{
if (!$renderable->isEnabled()) {
return false;
}

while ($renderable = $renderable->getParentRenderable()) {
if ($renderable instanceof RenderableInterface && !$renderable->isEnabled()) {
return false;
}
}

return true;
}
}

0 comments on commit 93eafd2

Please sign in to comment.