Project

General

Profile

Actions

Bug #102055

open

Form runtime next/previous page ignores variants

Added by Mathias Brodala 7 months ago. Updated 6 months ago.

Status:
Under Review
Priority:
Should have
Assignee:
-
Category:
Form Framework
Target version:
Start date:
2023-09-28
Due date:
% Done:

0%

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

Description

Given a form with conditional pages variants are not respected when the navigation is built. Example:

type: Form
prototypeName: standard
identifier: multi-step-form
label: Muli step form
renderables:
  -
    type: Page
    identifier: page-1
    label: First step
    renderables:
      -
        type: Checkbox
        identifier: checkbox-1
        label: Check this and the 2nd step will be skipped
  -
    type: Page
    identifier: page-2
    label: Second step
    renderingOptions:
      enabled: false
    variants:
      -
        identifier: variant-2
        condition: 'traverse(formValues, "checkbox-1") == 0'
        renderingOptions:
          enabled: true
  -
    type: Page
    identifier: page-3
    label: Third step
    renderingOptions:
      enabled: false
    variants:
      -
        identifier: variant-2
        condition: 'traverse(formValues, "checkbox-1") == 1'
        renderingOptions:
          enabled: true

Enabling the checkbox on the 1st page and going to the next page will show the 3rd page and a "Submit" button.

Not enabling the checkbox on the 1st page and going to the next page will show the 2nd page and a "Next Page" button. However, there is no next page here. In this case the button should also say "Submit".

The example above generally disables all subsequent pages and conditionally enables them which is a logical approach IMO. Especially because it allows you to have conditions which match their page 1:1. The reverse logic as suggested by the docs also doesn't work however:

type: Form
prototypeName: standard
identifier: multi-step-form
label: Muli step form
renderables:
  -
    type: Page
    identifier: page-1
    label: First step
    renderables:
      -
        type: Checkbox
        identifier: checkbox-1
        label: Check this and the 2nd step will be skipped
  -
    type: Page
    identifier: page-2
    label: Second step
    variants:
      -
        identifier: variant-2
        condition: 'traverse(formValues, "checkbox-1") == 1'
        renderingOptions:
          enabled: false
  -
    type: Page
    identifier: page-3
    label: Third step
    variants:
      -
        identifier: variant-2
        condition: 'traverse(formValues, "checkbox-1") == 0'
        renderingOptions:
          enabled: false
Actions #1

Updated by Mathias Brodala 7 months ago

  • Description updated (diff)
Actions #2

Updated by Mathias Brodala 7 months ago

  • Description updated (diff)
Actions #3

Updated by Gerrit Code Review 7 months 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/+/81271

Actions #4

Updated by Mathias Brodala 7 months ago

  • Description updated (diff)
  • Status changed from Under Review to New
Actions #5

Updated by Mathias Brodala 7 months ago

  • Description updated (diff)
Actions #6

Updated by Gerrit Code Review 7 months ago

  • Status changed from New to Under Review

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/+/81271

Actions #7

Updated by Mathias Brodala 6 months ago

Just noticed that the given example is bad since you always end up at the 3rd page with "Submit" then. Here is a better example:

type: Form
prototypeName: standard
identifier: multi-step-form
label: Muli step form
renderables:
  -
    type: Page
    identifier: page-1
    label: First step
    renderables:
      -
        type: Checkbox
        identifier: checkbox-1
        label: Check this and the 3rd step will be skipped
  -
    type: Page
    identifier: page-2
    label: Second step
    variants:
      -
        identifier: variant-2
        condition: 'traverse(formValues, "checkbox-1") == 0'
        renderingOptions:
          enabled: false
  -
    type: Page
    identifier: page-3
    label: Third step
    variants:
      -
        identifier: variant-2
        condition: 'traverse(formValues, "checkbox-1") == 1'
        renderingOptions:
          enabled: false

Without the fix, having the checkbox enabled will lead to "Next page" on the 2nd page as last step.

With the fix it will say "Submit" on the 2nd page instead since there is no 3rd page.

Actions

Also available in: Atom PDF