From f4570f98594cc5a8355f1a4ac4384ef55a267db8 Mon Sep 17 00:00:00 2001
From: Ralf Zimmermann <ralf.zimmermann@tritum.de>
Date: Mon, 3 Jul 2017 12:23:09 +0200
Subject: [PATCH] [BUGFIX] EXT:form - exclude hidden fields within summary
 pages and mails

Add a "renderingOptions" property called "_isHiddenFormElement" to
prevent form elements from being shown within summary pages and emails.

Resolves: #81770
Releases: master, 8.7
Change-Id: Iea3232879fc2be2cae00e5ed5cea565e68e192f3
Reviewed-on: https://review.typo3.org/53383
Reviewed-by: Daniel Lorenz <daniel.lorenz@extco.de>
Tested-by: Daniel Lorenz <daniel.lorenz@extco.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Bjoern Jacob <bjoern.jacob@tritum.de>
Tested-by: Bjoern Jacob <bjoern.jacob@tritum.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
---
 .../RenderAllFormValuesViewHelper.php         |  7 ++--
 .../form/Configuration/Yaml/BaseSetup.yaml    |  4 +++
 .../Config/configuration/Index.rst            |  4 +++
 .../formElements/formElementTypes/Hidden.rst  |  3 ++
 .../formElementTypes/Honeypot.rst             |  3 ++
 .../renderingOptions/_isHiddenFormElement.rst | 32 +++++++++++++++++++
 .../renderingOptions/_isHiddenFormElement.rst | 32 +++++++++++++++++++
 7 files changed, 83 insertions(+), 2 deletions(-)
 create mode 100644 typo3/sysext/form/Documentation/Config/prototypes/formElementsDefinition/formElementTypes/Hidden/renderingOptions/_isHiddenFormElement.rst
 create mode 100644 typo3/sysext/form/Documentation/Config/prototypes/formElementsDefinition/formElementTypes/Honeypot/renderingOptions/_isHiddenFormElement.rst

diff --git a/typo3/sysext/form/Classes/ViewHelpers/RenderAllFormValuesViewHelper.php b/typo3/sysext/form/Classes/ViewHelpers/RenderAllFormValuesViewHelper.php
index 29725a81c6d7..518c341d9664 100644
--- a/typo3/sysext/form/Classes/ViewHelpers/RenderAllFormValuesViewHelper.php
+++ b/typo3/sysext/form/Classes/ViewHelpers/RenderAllFormValuesViewHelper.php
@@ -84,10 +84,13 @@ class RenderAllFormValuesViewHelper extends AbstractViewHelper
 
             if (
                 !$element instanceof FormElementInterface
-                || $element->getType() === 'Honeypot'
                 || (
                     isset($renderingOptions['_isCompositeFormElement'])
-                    && $renderingOptions['_isCompositeFormElement'] = true
+                    && $renderingOptions['_isCompositeFormElement'] === true
+                )
+                || (
+                    isset($renderingOptions['_isHiddenFormElement'])
+                    && $renderingOptions['_isHiddenFormElement'] === true
                 )
             ) {
                 continue;
diff --git a/typo3/sysext/form/Configuration/Yaml/BaseSetup.yaml b/typo3/sysext/form/Configuration/Yaml/BaseSetup.yaml
index afebdb60ddef..dac7932fd680 100644
--- a/typo3/sysext/form/Configuration/Yaml/BaseSetup.yaml
+++ b/typo3/sysext/form/Configuration/Yaml/BaseSetup.yaml
@@ -149,10 +149,14 @@ TYPO3:
               properties:
                 renderAsHiddenField: false
                 styleAttribute: 'position:absolute; margin:0 0 0 -999em;'
+              renderingOptions:
+                _isHiddenFormElement: true
 
             Hidden:
               __inheritances:
                 10: 'TYPO3.CMS.Form.mixins.formElementMixins.FormElementMixin'
+              renderingOptions:
+                _isHiddenFormElement: true
 
             ### FORM ELEMENTS: HTML5 ###
             Email:
diff --git a/typo3/sysext/form/Documentation/Config/configuration/Index.rst b/typo3/sysext/form/Documentation/Config/configuration/Index.rst
index 7d020d9833e8..a95f026ca564 100644
--- a/typo3/sysext/form/Documentation/Config/configuration/Index.rst
+++ b/typo3/sysext/form/Documentation/Config/configuration/Index.rst
@@ -1784,6 +1784,8 @@ Full default configuration
               elementErrorClassAttribute: error
               renderAsHiddenField: false
               styleAttribute: 'position:absolute; margin:0 0 0 -999em;'
+            renderingOptions:
+              _isHiddenFormElement: true
           Hidden:
             formEditor:
               editors:
@@ -1836,6 +1838,8 @@ Full default configuration
               containerClassAttribute: input
               elementClassAttribute: ''
               elementErrorClassAttribute: error
+            renderingOptions:
+              _isHiddenFormElement: true
           Email:
             formEditor:
               editors:
diff --git a/typo3/sysext/form/Documentation/Config/proto/formElements/formElementTypes/Hidden.rst b/typo3/sysext/form/Documentation/Config/proto/formElements/formElementTypes/Hidden.rst
index 98b775ca30b8..ef81c922fea2 100644
--- a/typo3/sysext/form/Documentation/Config/proto/formElements/formElementTypes/Hidden.rst
+++ b/typo3/sysext/form/Documentation/Config/proto/formElements/formElementTypes/Hidden.rst
@@ -16,6 +16,9 @@ Properties
 .. _typo3.cms.form.prototypes.<prototypeIdentifier>.formelementsdefinition.hidden.implementationclassname:
 .. include:: Hidden/implementationClassName.rst
 
+.. _typo3.cms.form.prototypes.<prototypeIdentifier>.formelementsdefinition.hidden.renderingoptions._isHiddenFormElement:
+.. include:: Hidden/renderingOptions/_isHiddenFormElement.rst
+
 .. _typo3.cms.form.prototypes.<prototypeIdentifier>.formelementsdefinition.hidden.properties.containerclassattribute:
 .. include:: Hidden/properties/containerClassAttribute.rst
 
diff --git a/typo3/sysext/form/Documentation/Config/proto/formElements/formElementTypes/Honeypot.rst b/typo3/sysext/form/Documentation/Config/proto/formElements/formElementTypes/Honeypot.rst
index e0a691ea65bc..58534a910d3a 100644
--- a/typo3/sysext/form/Documentation/Config/proto/formElements/formElementTypes/Honeypot.rst
+++ b/typo3/sysext/form/Documentation/Config/proto/formElements/formElementTypes/Honeypot.rst
@@ -15,6 +15,9 @@ Properties
 .. _typo3.cms.form.prototypes.<prototypeIdentifier>.formelementsdefinition.honeypot.implementationclassname:
 .. include:: Honeypot/implementationClassName.rst
 
+.. _typo3.cms.form.prototypes.<prototypeIdentifier>.formelementsdefinition.honeypot.renderingoptions._isHiddenFormElement:
+.. include:: Honeypot/renderingOptions/_isHiddenFormElement.rst
+
 .. _typo3.cms.form.prototypes.<prototypeIdentifier>.formelementsdefinition.honeypot.properties.containerclassattribute:
 .. include:: Honeypot/properties/containerClassAttribute.rst
 
diff --git a/typo3/sysext/form/Documentation/Config/prototypes/formElementsDefinition/formElementTypes/Hidden/renderingOptions/_isHiddenFormElement.rst b/typo3/sysext/form/Documentation/Config/prototypes/formElementsDefinition/formElementTypes/Hidden/renderingOptions/_isHiddenFormElement.rst
new file mode 100644
index 000000000000..1ab6b1836c93
--- /dev/null
+++ b/typo3/sysext/form/Documentation/Config/prototypes/formElementsDefinition/formElementTypes/Hidden/renderingOptions/_isHiddenFormElement.rst
@@ -0,0 +1,32 @@
+renderingOptions._isHiddenFormElement
+-------------------------------------
+
+:aspect:`Option path`
+      TYPO3.CMS.Form.prototypes.<prototypeIdentifier>.formElementsDefinition.Hidden.renderingOptions._isHiddenFormElement
+
+:aspect:`Data type`
+      bool
+
+:aspect:`Needed by`
+      Frontend
+
+:aspect:`Overwritable within form definition`
+      Yes
+
+:aspect:`form editor can write this property into the form definition (for prototype 'standard')`
+      No
+
+:aspect:`Mandatory`
+      No
+
+:aspect:`Default value (for prototype 'standard')`
+      .. code-block:: yaml
+         :linenos:
+         :emphasize-lines: 3
+
+         Hidden:
+           renderingOptions:
+             _isHiddenFormElement: true
+
+:aspect:`Description`
+      Internal control setting to define that the form element is not visible within the summary page and emails.
\ No newline at end of file
diff --git a/typo3/sysext/form/Documentation/Config/prototypes/formElementsDefinition/formElementTypes/Honeypot/renderingOptions/_isHiddenFormElement.rst b/typo3/sysext/form/Documentation/Config/prototypes/formElementsDefinition/formElementTypes/Honeypot/renderingOptions/_isHiddenFormElement.rst
new file mode 100644
index 000000000000..0c7cd5bbde9f
--- /dev/null
+++ b/typo3/sysext/form/Documentation/Config/prototypes/formElementsDefinition/formElementTypes/Honeypot/renderingOptions/_isHiddenFormElement.rst
@@ -0,0 +1,32 @@
+renderingOptions._isHiddenFormElement
+-------------------------------------
+
+:aspect:`Option path`
+      TYPO3.CMS.Form.prototypes.<prototypeIdentifier>.formElementsDefinition.Honeypot.renderingOptions._isHiddenFormElement
+
+:aspect:`Data type`
+      bool
+
+:aspect:`Needed by`
+      Frontend
+
+:aspect:`Overwritable within form definition`
+      Yes
+
+:aspect:`form editor can write this property into the form definition (for prototype 'standard')`
+      No
+
+:aspect:`Mandatory`
+      No
+
+:aspect:`Default value (for prototype 'standard')`
+      .. code-block:: yaml
+         :linenos:
+         :emphasize-lines: 3
+
+         Honeypot:
+           renderingOptions:
+             _isHiddenFormElement: true
+
+:aspect:`Description`
+      Internal control setting to define that the form element is not visible within the summary page and emails.
\ No newline at end of file
-- 
GitLab