[+BUGFIX] Fluid (ViewHelpers): Fix bug in Form ViewHelper
authorSebastian Kurfürst <sebastian@typo3.org>
Wed, 22 Sep 2010 06:27:32 +0000 (06:27 +0000)
committerSebastian Kurfürst <sebastian@typo3.org>
Wed, 22 Sep 2010 06:27:32 +0000 (06:27 +0000)
Since #6521 you can use the "objectName" argument to specify the name of a bound object rather then using the "name" attribute.
But if you do so, the rendered hidden identity field is not correct anymore. This behavior is fixed with this commit.

Resolves: #9515

typo3/sysext/fluid/Classes/ViewHelpers/FormViewHelper.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/FormViewHelperTest.php

index 7e20aac..e04cb3a 100644 (file)
@@ -140,7 +140,7 @@ class Tx_Fluid_ViewHelpers_FormViewHelper extends Tx_Fluid_ViewHelpers_Form_Abst
                $formContent = $this->renderChildren();
 
                $content = chr(10) . '<div style="display: none">';
-               $content .= $this->renderHiddenIdentityField($this->arguments['object'], $this->arguments['name']);
+               $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
index 8a2d370..2afb7b6 100644 (file)
@@ -96,12 +96,14 @@ class Tx_Fluid_ViewHelpers_FormViewHelperTest extends Tx_Fluid_ViewHelpers_ViewH
        /**
         * @test
         * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @author Bastian Waidelich <bastian@typo3.org>
         */
        public function renderCallsRenderHiddenIdentityField() {
                $object = new stdClass();
-               $viewHelper = $this->getAccessibleMock('Tx_Fluid_ViewHelpers_FormViewHelper', array('renderChildren', 'renderRequestHashField', 'renderHiddenIdentityField'), array(), '', FALSE);
+               $viewHelper = $this->getAccessibleMock('Tx_Fluid_ViewHelpers_FormViewHelper', array('renderChildren', 'renderRequestHashField', 'renderHiddenIdentityField', 'getFormObjectName'), array(), '', FALSE);
                $this->injectDependenciesIntoViewHelper($viewHelper);
-               $viewHelper->setArguments(new Tx_Fluid_Core_ViewHelper_Arguments(array('object' => $object, 'name' => 'MyName')));
+               $viewHelper->setArguments(new Tx_Fluid_Core_ViewHelper_Arguments(array('object' => $object)));
+               $viewHelper->expects($this->atLeastOnce())->method('getFormObjectName')->will($this->returnValue('MyName'));
                $viewHelper->expects($this->once())->method('renderHiddenIdentityField')->with($object, 'MyName');
 
                $viewHelper->render();