[BUGFIX] FormViewHelper creates inline styling
authorAnja Leichsenring <aleichsenring@ab-softlab.de>
Mon, 1 Apr 2013 08:54:06 +0000 (10:54 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Mon, 1 Apr 2013 10:45:58 +0000 (12:45 +0200)
Due to accessibility reasons the inline styling of a container is
removed.

Fixes: #40826
Fluid Package Issue: #42743
Releases: 6.0, 4.7, 1.3
Change-Id: Ic78187422b0f50c52da7c288b36ca640d780b15a
Reviewed-on: https://review.typo3.org/19479
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
typo3/sysext/fluid/Classes/ViewHelpers/FormViewHelper.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/FormViewHelperTest.php

index 34e4725..22bef5c 100644 (file)
@@ -120,9 +120,10 @@ class Tx_Fluid_ViewHelpers_FormViewHelper extends Tx_Fluid_ViewHelpers_Form_Abst
         * @param string $fieldNamePrefix Prefix that will be added to all field names within this form. If not set the prefix will be tx_yourExtension_plugin
         * @param string $actionUri can be used to overwrite the "action" attribute of the form tag
         * @param string $objectName name of the object that is bound to this form. If this argument is not specified, the name attribute of this form is used to determine the FormObjectName
+        * @param string $hiddenFieldClassName
         * @return string rendered form
         */
-       public function render($action = NULL, array $arguments = array(), $controller = NULL, $extensionName = NULL, $pluginName = NULL, $pageUid = NULL, $object = NULL, $pageType = 0, $noCache = FALSE, $noCacheHash = FALSE, $section = '', $format = '', array $additionalParams = array(), $absolute = FALSE, $addQueryString = FALSE, array $argumentsToBeExcludedFromQueryString = array(), $fieldNamePrefix = NULL, $actionUri = NULL, $objectName = NULL) {
+       public function render($action = NULL, array $arguments = array(), $controller = NULL, $extensionName = NULL, $pluginName = NULL, $pageUid = NULL, $object = NULL, $pageType = 0, $noCache = FALSE, $noCacheHash = FALSE, $section = '', $format = '', array $additionalParams = array(), $absolute = FALSE, $addQueryString = FALSE, array $argumentsToBeExcludedFromQueryString = array(), $fieldNamePrefix = NULL, $actionUri = NULL, $objectName = NULL, $hiddenFieldClassName = NULL) {
                $this->setFormActionUri();
 
                if (strtolower($this->arguments['method']) === 'get') {
@@ -138,12 +139,16 @@ class Tx_Fluid_ViewHelpers_FormViewHelper extends Tx_Fluid_ViewHelpers_Form_Abst
 
                $formContent = $this->renderChildren();
 
-               $content = chr(10) . '<div style="display: none">';
+               if ($this->arguments['hiddenFieldClassName'] !== NULL) {
+                       $content = LF . '<div class="' . htmlspecialchars($this->arguments['hiddenFieldClassName']) . '">';
+               } else {
+                       $content = LF . '<div style="display: none">';
+               }
                $content .= $this->renderHiddenIdentityField($this->arguments['object'], $this->getFormObjectName());
                $content .= $this->renderAdditionalIdentityFields();
                $content .= $this->renderHiddenReferrerFields();
                $content .= $this->renderRequestHashField(); // Render hmac after everything else has been rendered
-               $content .= chr(10) . '</div>' . chr(10);
+               $content .= LF . '</div>' . LF;
                $content .= $formContent;
 
                $this->tag->setContent($content);
index 1ad4fe3..2a7af9b 100644 (file)
@@ -140,6 +140,39 @@ class Tx_Fluid_Tests_Unit_ViewHelpers_FormViewHelperTest extends Tx_Fluid_ViewHe
                $viewHelper->render();
        }
 
+       /**
+        * @test
+        */
+       public function renderWrapsHiddenFieldsWithDivForXhtmlCompatibilityWithDeprecatedPropertyMapper() {
+               /** @var $viewHelper Tx_Fluid_ViewHelpers_FormViewHelper */
+               $viewHelper = $this->getMock($this->buildAccessibleProxy('Tx_Fluid_ViewHelpers_FormViewHelper'), array('renderChildren', 'renderHiddenIdentityField', 'renderAdditionalIdentityFields', 'renderHiddenReferrerFields', 'renderTrustedPropertiesField', 'renderRequestHashField'), array(), '', FALSE);
+               parent::injectDependenciesIntoViewHelper($viewHelper);
+               $viewHelper->expects($this->once())->method('renderHiddenIdentityField')->will($this->returnValue('hiddenIdentityField'));
+               $viewHelper->expects($this->once())->method('renderAdditionalIdentityFields')->will($this->returnValue('additionalIdentityFields'));
+               $viewHelper->expects($this->once())->method('renderHiddenReferrerFields')->will($this->returnValue('hiddenReferrerFields'));
+               $viewHelper->expects($this->once())->method('renderChildren')->will($this->returnValue('formContent'));
+               $expectedResult = LF . '<div style="display: none">' . 'hiddenIdentityFieldadditionalIdentityFieldshiddenReferrerFields' . LF . '</div>' . LF . 'formContent';
+               $this->tagBuilder->expects($this->once())->method('setContent')->with($expectedResult);
+               $viewHelper->render();
+       }
+
+       /**
+        * @test
+        */
+       public function renderWrapsHiddenFieldsWithDivAndAnAdditionalClassForXhtmlCompatibilityWithDeprecatedPropertyMapper() {
+               $viewHelper = $this->getMock($this->buildAccessibleProxy('Tx_Fluid_ViewHelpers_FormViewHelper'), array('renderChildren', 'renderHiddenIdentityField', 'renderAdditionalIdentityFields', 'renderHiddenReferrerFields', 'renderTrustedPropertiesField', 'renderRequestHashField'), array(), '', FALSE);
+               $configurationManager = $this->getMock('Tx_Extbase_Configuration_ConfigurationManager', array('isFeatureEnabled'));
+               $viewHelper->injectConfigurationManager($configurationManager);
+               parent::injectDependenciesIntoViewHelper($viewHelper);
+               $viewHelper->expects($this->once())->method('renderHiddenIdentityField')->will($this->returnValue('hiddenIdentityField'));
+               $viewHelper->expects($this->once())->method('renderAdditionalIdentityFields')->will($this->returnValue('additionalIdentityFields'));
+               $viewHelper->expects($this->once())->method('renderHiddenReferrerFields')->will($this->returnValue('hiddenReferrerFields'));
+               $viewHelper->expects($this->once())->method('renderChildren')->will($this->returnValue('formContent'));
+               $expectedResult = LF . '<div class="hidden">' . 'hiddenIdentityFieldadditionalIdentityFieldshiddenReferrerFields' . LF . '</div>' . LF . 'formContent';
+               $this->tagBuilder->expects($this->once())->method('setContent')->with($expectedResult);
+               $viewHelper->setArguments(array('hiddenFieldClassName' => 'hidden'));
+               $viewHelper->render();
+       }
 
        /**
         * @test