Project

General

Profile

Actions

Feature #84133

closed

Epic #84132: Introduce variants

Variants - Frontend implementation

Added by Ralf Zimmermann over 6 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Should have
Category:
Form Framework
Target version:
Start date:
2018-05-24
Due date:
% Done:

100%

Estimated time:
(Total: 0.00 h)
PHP Version:
Tags:
Complexity:
Sprint Focus:
On Location Sprint

Description

Variants allow you to change properties of a form element.
Variants can be made under conditions.
This makes it possible to manipulate form element values, validator options, and finisher options based on conditions.
The allows among other things:

  • translation of form element values depending on the frontend language
  • set and remove validators of one form element depending on the value of another form element
  • hide entire pages depending on the value of a form element
  • set finisher values depending on the value of a form element
  • hiding a form element in certain finishers and on the summary page
  • and much more

This feature implements variants for frontend rendering and the ability to define variants in the formDefinition.
The implementation to define variants in the form editor is done in a separate patchset.

Examples

    # translation of form element values depending on the frontend language

    type: Form
    identifier: test
    prototypeName: standard
    label: DE
    renderingOptions:
      submitButtonLabel: Abschicken
    variants:
      -
        identifier: language-variant-1
        condition: 'siteLanguage.getLocale() == "en_US.UTF-8"'
        label: EN
        renderingOptions:
          submitButtonLabel: Submit
    renderables:
      -
        type: Page
        identifier: page-1
        label: DE
        renderingOptions:
          previousButtonLabel: 'zurück'
          nextButtonLabel: 'weiter'
        variants:
          -
            identifier: language-variant-1
            condition: 'siteLanguage.getLocale() == "en_US.UTF-8"'
            label: EN
            renderingOptions:
              previousButtonLabel: 'Previous step'
              nextButtonLabel: 'Next step'
        renderables:
          -
            type: Text
            identifier: text-1
            label: DE
            properties:
              fluidAdditionalAttributes:
                placeholder: Platzhalter
            variants:
              -
                identifier: language-variant-1
                condition: 'siteLanguage.getLocale() == "en_US.UTF-8"'
                label: EN
                properties:
                  fluidAdditionalAttributes:
                    placeholder: Placeholder
    # set validators of one form element depending on the value of another form element

    type: Form
    identifier: test
    label: test
    prototypeName: standard
    renderables:
      -
        type: Page
        identifier: page-1
        label: Step
        renderables:
          -
            defaultValue: ''
            type: Text
            identifier: text-1
            label: 'Email address'
            variants:
              -
                identifier: variant-1
                condition: 'formValues["checkbox-1"] == 1'
                properties:
                  fluidAdditionalAttributes:
                    required: 'required'
                validators:
                  -
                    identifier: NotEmpty 
                  -
                    identifier: EmailAddress 
          -
            type: Checkbox
            identifier: checkbox-1
            label: 'Subscribe to newsletter'
    # hide entire steps (form pages) depending on the value of a form element (needs https://review.typo3.org/#/c/57049/)

    type: Form
    identifier: test
    prototypeName: standard
    label: Test
    renderables:
      -
        type: Page
        identifier: page-1
        label: 'Page 1'
        renderables:
          -
            type: Text
            identifier: text-1
            label: 'Text 1'
          -
            type: Checkbox
            identifier: checkbox-1
            label: 'Skip page 2'
            variants:
              -
                identifier: hide-1
                condition: 'stepType == "SummaryPage"'
                renderingOptions:
                  enabled: false
      -
        type: Page
        identifier: page-2
        label: 'Page 2'
        variants:
          -
            identifier: variant-1
            condition: 'formValues["checkbox-1"] == 1'
            renderingOptions:
              enabled: false
        renderables:
          -
            type: Text
            identifier: text-2
            label: 'Text 2'
      -
        type: SummaryPage
        identifier: summarypage-1
        label: 'Summary step'

    # set finisher values depending on the application context

    type: Form
    identifier: test
    prototypeName: standard
    label: Test
    renderingOptions:
      submitButtonLabel: Submit
    finishers:
      -
        identifier: Confirmation
        options:
          message: 'Thank you'
    variants:
      -
        identifier: variant-1
        condition: 'applicationContext matches "#Production/Local#"'
        finishers:
          -
            identifier: Confirmation
            options:
              message: 'ouy knahT'
    renderables:
      -
        type: Page
        identifier: page-1
        label: 'Page 1'
        renderingOptions:
          previousButtonLabel: 'Previous step'
          nextButtonLabel: 'Next step'
    # hiding a form element in certain finishers and on the summary step (needs https://review.typo3.org/#/c/57049/)

    type: Form
    identifier: test
    prototypeName: standard
    label: Test
    finishers:
      -
        identifier: EmailToReceiver
        options:
          subject: Testmail
          recipientAddress: tritum@example.org
          recipientName: 'Test'
          senderAddress: tritum@example.org
          senderName: tritum@example.org
    renderables:
      -
        type: Page
        identifier: page-1
        label: 'Page 1'
        renderables:
          -
            type: Text
            identifier: text-1
            label: 'Text 1'
            variants:
              -
                identifier: hide-1
                renderingOptions:
                  enabled: false
                condition: 'stepType == "SummaryPage" || finisherIdentifier in ["EmailToSender", "EmailToReceiver"]'
          -
            type: Text
            identifier: text-2
            label: 'Text 2'
      -
        type: SummaryPage
        identifier: summarypage-1
        label: 'Summary step'

Subtasks 2 (0 open2 closed)

Task #85072: Move property merge behaviorClosedRalf Zimmermann2018-05-24

Actions
Feature #85080: Add a property to control the visibility for form elementsClosedRalf Zimmermann2018-05-25

Actions

Related issues 6 (0 open6 closed)

Related to TYPO3 Core - Feature #83673: Make forms of EXT:form translateableClosed2018-01-24

Actions
Related to TYPO3 Core - Task #82706: Fieldset labels missing in mailsClosedMathias Brodala2017-10-09

Actions
Related to TYPO3 Core - Feature #81593: Usage of constants in YAML filesClosed2017-06-16

Actions
Related to TYPO3 Core - Feature #82211: Allow generlOverride in formDefinitionOverridesClosed2017-08-26

Actions
Related to TYPO3 Core - Task #86196: Centralize ExpressionLanguage Registration via APIClosedSusanne Moog2018-09-07

Actions
Precedes TYPO3 Core - Task #86462: form: Add documentation for variantsClosed2018-05-25

Actions
Actions

Also available in: Atom PDF