Feature #84133

Epic #84132: Introduce variants

Variants - Frontend implementation

Added by Ralf Zimmermann over 1 year ago. Updated about 1 year ago.

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

100%

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

Task #85072: Move property merge behaviorClosedRalf Zimmermann

Feature #85080: Add a property to control the visibility for form elementsClosedRalf Zimmermann


Related issues

Related to TYPO3 Core - Feature #83673: Make forms of EXT:form translateable Closed 2018-01-24
Related to TYPO3 Core - Task #82706: Fieldset labels missing in mails Accepted 2017-10-09
Related to TYPO3 Core - Feature #81593: Usage of constants in YAML files New 2017-06-16
Related to TYPO3 Core - Feature #82211: Allow generlOverride in formDefinitionOverrides Closed 2017-08-26
Related to TYPO3 Core - Task #86196: Centralize ExpressionLanguage Registration via API Closed 2018-09-07
Precedes TYPO3 Core - Task #86462: form: Add documentation for variants Closed 2018-05-25

Associated revisions

Revision 0dcb8970 (diff)
Added by Ralf Zimmermann over 1 year ago

[FEATURE] Introduce conditional variants for form elements

Variants allow you to change properties of a form element.

Variants can contain conditions. If a concrete condition
is TRUE the variant is applied. If no condition exists the
variant will be ignored.

Variants make it possible to manipulate form element values,
validator options, and finisher options based on conditions.
This allows you 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

This feature implements variants for the frontend rendering and
the ability to define variants in the formDefinition. The
implementation to define variants in the form editor is out of
scope of this patchset.

Releases: master
Resolves: #84133
Change-Id: I9efeeea5af67df2d2f9252339c26baf8a03cf9c8
Reviewed-on: https://review.typo3.org/54982
Tested-by: TYPO3com <>
Reviewed-by: Björn Jacob <>
Tested-by: Björn Jacob <>
Reviewed-by: Andreas Fernandez <>
Tested-by: Andreas Fernandez <>
Reviewed-by: Anja Leichsenring <>
Tested-by: Anja Leichsenring <>

History

#1 Updated by Gerrit Code Review over 1 year ago

  • Status changed from New to Under Review

Patch set 12 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#2 Updated by Ralf Zimmermann over 1 year ago

  • Subject changed from Frontend implementation to Variants - Frontend implementation

#3 Updated by Gerrit Code Review over 1 year ago

Patch set 13 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#4 Updated by Gerrit Code Review over 1 year ago

Patch set 14 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#5 Updated by Gerrit Code Review over 1 year ago

Patch set 15 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#6 Updated by Gerrit Code Review over 1 year ago

Patch set 16 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#7 Updated by Ralf Zimmermann over 1 year ago

  • Description updated (diff)

#8 Updated by Gerrit Code Review over 1 year ago

Patch set 17 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#9 Updated by Ralf Zimmermann over 1 year ago

  • Related to Feature #83673: Make forms of EXT:form translateable added

#10 Updated by Gerrit Code Review over 1 year ago

Patch set 18 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#11 Updated by Gerrit Code Review over 1 year ago

Patch set 19 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#12 Updated by Mathias Brodala over 1 year ago

  • Sprint Focus set to On Location Sprint

Will try to review this in the upcoming sprint.

#13 Updated by Gerrit Code Review over 1 year ago

Patch set 20 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#14 Updated by Ralf Zimmermann over 1 year ago

  • Description updated (diff)

#15 Updated by Gerrit Code Review over 1 year ago

Patch set 21 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#16 Updated by Gerrit Code Review over 1 year ago

Patch set 22 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#17 Updated by Gerrit Code Review over 1 year ago

Patch set 23 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#18 Updated by Gerrit Code Review over 1 year ago

Patch set 24 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#19 Updated by Ralf Zimmermann over 1 year ago

  • Related to Task #82706: Fieldset labels missing in mails added

#20 Updated by Ralf Zimmermann over 1 year ago

#21 Updated by Ralf Zimmermann over 1 year ago

  • Related to Feature #82211: Allow generlOverride in formDefinitionOverrides added

#22 Updated by Gerrit Code Review over 1 year ago

Patch set 25 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#23 Updated by Gerrit Code Review over 1 year ago

Patch set 26 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#24 Updated by Gerrit Code Review over 1 year ago

Patch set 27 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#25 Updated by Gerrit Code Review over 1 year ago

Patch set 28 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#26 Updated by Gerrit Code Review over 1 year ago

Patch set 29 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#27 Updated by Bjoern Jacob over 1 year ago

  • Sprint Focus changed from On Location Sprint to Remote Sprint

#28 Updated by Gerrit Code Review over 1 year ago

Patch set 31 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#29 Updated by Gerrit Code Review over 1 year ago

Patch set 32 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#30 Updated by Gerrit Code Review over 1 year ago

Patch set 33 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#31 Updated by Gerrit Code Review over 1 year ago

Patch set 34 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#32 Updated by Gerrit Code Review over 1 year ago

Patch set 35 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#33 Updated by Gerrit Code Review over 1 year ago

Patch set 36 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#34 Updated by Gerrit Code Review over 1 year ago

Patch set 37 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#35 Updated by Ralf Zimmermann over 1 year ago

  • Description updated (diff)

#36 Updated by Ralf Zimmermann over 1 year ago

  • Description updated (diff)

#37 Updated by Ralf Zimmermann over 1 year ago

  • Description updated (diff)

#38 Updated by Gerrit Code Review over 1 year ago

Patch set 38 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#39 Updated by Ralf Zimmermann over 1 year ago

  • Description updated (diff)

#40 Updated by Ralf Zimmermann over 1 year ago

  • Description updated (diff)

#41 Updated by Gerrit Code Review over 1 year ago

Patch set 39 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#42 Updated by Gerrit Code Review over 1 year ago

Patch set 40 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#43 Updated by Gerrit Code Review over 1 year ago

Patch set 41 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#44 Updated by Gerrit Code Review over 1 year ago

Patch set 42 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#45 Updated by Gerrit Code Review over 1 year ago

Patch set 43 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#46 Updated by Gerrit Code Review over 1 year ago

Patch set 44 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#47 Updated by Gerrit Code Review over 1 year ago

Patch set 45 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#48 Updated by Gerrit Code Review over 1 year ago

Patch set 46 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#49 Updated by Gerrit Code Review over 1 year ago

Patch set 47 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#50 Updated by Gerrit Code Review over 1 year ago

Patch set 48 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#51 Updated by Gerrit Code Review over 1 year ago

Patch set 49 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#52 Updated by Anja Leichsenring over 1 year ago

  • Sprint Focus changed from Remote Sprint to On Location Sprint

#53 Updated by Gerrit Code Review over 1 year ago

Patch set 50 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#54 Updated by Gerrit Code Review over 1 year ago

Patch set 51 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#55 Updated by Gerrit Code Review over 1 year ago

Patch set 52 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#56 Updated by Gerrit Code Review over 1 year ago

Patch set 53 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#57 Updated by Gerrit Code Review over 1 year ago

Patch set 54 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#58 Updated by Gerrit Code Review over 1 year ago

Patch set 55 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#59 Updated by Gerrit Code Review over 1 year ago

Patch set 56 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#60 Updated by Gerrit Code Review over 1 year ago

Patch set 57 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#61 Updated by Gerrit Code Review over 1 year ago

Patch set 58 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#62 Updated by Gerrit Code Review over 1 year ago

Patch set 59 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#63 Updated by Gerrit Code Review over 1 year ago

Patch set 60 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#64 Updated by Gerrit Code Review over 1 year ago

Patch set 61 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#65 Updated by Gerrit Code Review over 1 year ago

Patch set 62 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#66 Updated by Gerrit Code Review over 1 year ago

Patch set 63 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54982

#67 Updated by Ralf Zimmermann over 1 year ago

  • Status changed from Under Review to Resolved

#68 Updated by Susanne Moog about 1 year ago

  • Related to Task #86196: Centralize ExpressionLanguage Registration via API added

#69 Updated by Stefan Neufeind about 1 year ago

  • Precedes Task #86462: form: Add documentation for variants added

#70 Updated by Benni Mack about 1 year ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF