Bug #90083

Validators are empty if the same form is rendered multiple times on a page

Added by Ralf Zimmermann 5 months ago. Updated 3 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Form Framework
Target version:
-
Start date:
2020-01-10
Due date:
% Done:

100%

TYPO3 Version:
9
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

There are scenarios in which the same form is rendered several times even though it is only output once on the page.
Assuming there is a form plugin with a form with validators on form elements on colPos 10, the following setup would render the plugin twice and output the second rendered plugin.

setup.typoscript

page = PAGE
page {
    10 = FLUIDTEMPLATE
    10 {
        file = EXT:site_package/Resources/Private/Templates/Index.html

        variables {
            content-col-10 < styles.content.get
            content-col-10.select.where = colPos=10
        }
    }
}

lib.getSomeColPos = CONTENT
lib.getSomeColPos {
    table = tt_content
    select.where = colPos=10
    select.orderBy = sorting
}

EXT:site_package/Resources/Private/Templates/Index.html

<f:cObject typoscriptObjectPath="lib.getSomeColPos"/>

The result is that the validators are missing in the 2nd rendered form.
This is because when the validators are added, a runtime cache is used to prevent validators from being added twice (needed due to internal processes).
When rendering the same 2. form no more validators are added because the form element is not identified clearly enough.

A simple test to fake such a scenario without much effort would be:

setup.typoscript

page = PAGE
page {
    10 = FLUIDTEMPLATE
    10 {
        file = EXT:site_package/Resources/Private/Templates/Index.html

        variables {
            content < styles.content.get
            content-foo < styles.content.get
        }
    }
}

EXT:site_package/Resources/Private/Templates/Index.html

{content-foo -> f:format.raw()}

or

setup.typoscript

page = PAGE
page {
    10 = FLUIDTEMPLATE
    10 {
        file = EXT:site_package/Resources/Private/Templates/CustomContentElement.html
        settings {
            persistenceIdentifier = 1:/form_definitions/test.form.yaml
        }
        extbase.pluginName = Form
        extbase.controllerExtensionName = Formframework
        extbase.controllerName = FormFrontend
        extbase.controllerActionName = perform
    }
}

EXT:site_package/Resources/Private/Templates/CustomContentElement.html

<formvh:render persistenceIdentifier="{settings.persistenceIdentifier}" />
<formvh:render persistenceIdentifier="{settings.persistenceIdentifier}" />

1:/form_definitions/test.form.yaml

type: Form
identifier: test
label: test
prototypeName: standard
renderables:
  -
    type: Page
    identifier: page-1
    label: Step
    renderables:
      -
        defaultValue: ''
        type: Text
        identifier: text-1
        label: Text 1
      -
        defaultValue: ''
        type: Text
        identifier: text-2
        label: Text 2
        properties:
          fluidAdditionalAttributes:
            required: required
        validators:
          -
            identifier: NotEmpty
      -
        defaultValue: ''
        type: Text
        identifier: text-3
        label: Text 3
        properties:
          fluidAdditionalAttributes:
            required: required
        validators:
          -
            identifier: NotEmpty
  -
    type: SummaryPage
    identifier: summarypage-1
    label: 'Summary step'

result:

validators.png View (17.8 KB) Ralf Zimmermann, 2020-01-10 13:06


Related issues

Related to TYPO3 Core - Bug #88730: Validators of a field with the same identifier is working only once on a page Closed 2019-07-11
Related to TYPO3 Core - Bug #89236: TYPO3 Forms Extension: Required - Indicators (*) are not shown Closed 2019-09-24

Associated revisions

Revision dbaa9dbc (diff)
Added by Ralf Zimmermann 3 months ago

[BUGFIX] Respect form element instance for validators

Make sure to apply all configured validators if a form is rendered
multiple times on the same page.

Resolves: #90083
Releases: master, 9.5
Change-Id: Ife1a8beb985cde4fdb7c635fd98f4e7bc5ccb9db
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62840
Tested-by: TYPO3com <>
Tested-by: Björn Jacob <>
Tested-by: Ralf Zimmermann <>
Reviewed-by: Steffen Frese <>
Reviewed-by: Sascha Rademacher <>
Reviewed-by: Björn Jacob <>
Reviewed-by: Ralf Zimmermann <>

Revision 10b5e6e9 (diff)
Added by Ralf Zimmermann 3 months ago

[BUGFIX] Respect form element instance for validators

Make sure to apply all configured validators if a form is rendered
multiple times on the same page.

Resolves: #90083
Releases: master, 9.5
Change-Id: Ife1a8beb985cde4fdb7c635fd98f4e7bc5ccb9db
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63230
Tested-by: TYPO3com <>
Tested-by: Ralf Zimmermann <>
Reviewed-by: Ralf Zimmermann <>

History

#1 Updated by Ralf Zimmermann 5 months ago

  • Related to Bug #88730: Validators of a field with the same identifier is working only once on a page added

#2 Updated by Ralf Zimmermann 5 months ago

  • Related to Bug #89236: TYPO3 Forms Extension: Required - Indicators (*) are not shown added

#3 Updated by Gerrit Code Review 5 months ago

  • Status changed from New to Under Review

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

#4 Updated by Ralf Zimmermann 4 months ago

  • Description updated (diff)

#5 Updated by Gerrit Code Review 3 months ago

Patch set 1 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63230

#6 Updated by Ralf Zimmermann 3 months ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

#7 Updated by Gerrit Code Review 3 months ago

  • Status changed from Resolved to Under Review

Patch set 2 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63230

#8 Updated by Ralf Zimmermann 3 months ago

  • Status changed from Under Review to Resolved

#9 Updated by Benni Mack 3 months ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF