[BUGFIX] FormFieldVH->getPropertyValue() must work without form object 81/21181/6
authorAlexander Schnitzler <alex.schnitzler@typovision.de>
Sat, 1 Jun 2013 08:32:19 +0000 (10:32 +0200)
committerAlexander Schnitzler <typo3@alexanderschnitzler.de>
Tue, 4 Jun 2013 19:05:01 +0000 (21:05 +0200)
Since the new property mapper is active by default it is
possible to create forms without object="{object}", e.g.
using a newAction. This leads to some view helpers throwing
an exception as they rely on a present object to receive the
property value. As this object may not be present a missing
check has to be added to method getPropertyValue().

This check also exists in Flow.Fluid and is necessary to
fix malfunctioning view helpers.

Releases: 6.2, 6.1
Resolves: #48750
Relates: #48628
Change-Id: I6c42725d6daf9003358f8b6fbe9af3e62f011213
Reviewed-on: https://review.typo3.org/21181
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Alexander Schnitzler
Tested-by: Alexander Schnitzler
typo3/sysext/fluid/Classes/ViewHelpers/Form/AbstractFormFieldViewHelper.php

index 7a21192..a641b3c 100644 (file)
@@ -177,6 +177,9 @@ abstract class AbstractFormFieldViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\
         * @return mixed Value
         */
        protected function getPropertyValue() {
+               if (!$this->viewHelperVariableContainer->exists('TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper', 'formObject')) {
+                       return NULL;
+               }
                $formObject = $this->viewHelperVariableContainer->get('TYPO3\\CMS\\Fluid\\ViewHelpers\\FormViewHelper', 'formObject');
                $propertyName = $this->arguments['property'];
                if (is_array($formObject)) {