Project

General

Profile

Actions

Bug #101455

open

Form variants including a check on stepType == "Page" are always true, even in finishers and SummaryPage

Added by Stefan P 9 months ago. Updated 9 months ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Form Framework
Target version:
-
Start date:
2023-07-27
Due date:
% Done:

0%

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

Description

I have a custom Form Element defintion, having the following rendering options with variants. It should always be disabled but has a variant that enables it on "Page" steps.

renderingOptions:
    enabled: false
variants:
    - identifier: showOnlyOnPages
      renderingOptions:
          enabled: true
      condition: 'stepType == "Page"'

With this configuration the field is always rendered, however, also in finishers and on the SummaryPage!

When changing the condition to stepType == "NotExistingType" it is never shown, not on Page, not on SummaryPage, not in finishers. So the condition itself is actually evaluated somewhat correctly. But why do SummaryPage and finishers are considered to be of step type "Page"? I can't imagine this to be correct behaviour.

Actions #1

Updated by Stefan P 9 months ago

Using the inverse (always enabled, disable on specific conditions) is no option for me, because I want to disable it in every finisher and step Type, except Page! So I can not just query for 'stepType == "SummaryPage" || finisherIdentifier in ["EmailToSender", "EmailToReceiver"]' because this would enable it in custom finsishers and custom page types that are not explicitly in this exclusion-list.

Actions #2

Updated by Stefan P 9 months ago

  • Description updated (diff)
Actions #3

Updated by Stefan P 9 months ago

In FormRuntime::getConditionResolver, called by processVariants(), I see this:

$page = $this->getCurrentPage() ?? $this->getFormDefinition()->getPageByIndex(0);

So, even in finishers you are basically on a stepType "Page". And for the "SummaryPage" this happens because processVariants() is also called from initialize(), but BEFORE the currentPage is initialized.

This means:

processVariants() is always executed twice. Always at initialize() ( before the current stepType is known and falls back to Page then) and then either when rendering (on summary page it is then "SummaryPage") or when finishing (it is then "Page"). But the first initialize() call already makes stepType == "Page" always true in any case.

Actions #4

Updated by Stefan P 9 months ago

My current workaround is this: field always enabled, but disable on non-Page steps and when any finisher is executed. This seemingly covers all cases, but you never know. Having it work "forward" instead of "backwards" would be better.

variants:
    - identifier: showOnlyOnPages
      renderingOptions:
          enabled: false
      condition: 'stepType != "Page" || finisherIdentifier != ""'

Actions

Also available in: Atom PDF