[BUGFIX] Submitted form data has precedence over value argument 98/42298/5
authorMarkus Guenther <mail@markus-guenther.de>
Wed, 5 Aug 2015 21:03:52 +0000 (23:03 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Thu, 6 Aug 2015 17:10:45 +0000 (19:10 +0200)
This adjusts the behavior of all Form ViewHelpers so that any
submitted value is redisplayed even if a "value" argument has been
specified.

The issue with this, however, was that upon re-display of the form due
to property-mapping or validation errors the value argument had
precedence over the previously submitted value.

This is a breaking change if you expect the previous behavior of form
ViewHelpers always being pre-populated with the specified value
attribute / bound object property even when re-displaying the form upon
validation errors.
Besides this change deprecates
``AbstractFormFieldViewHelper::getValue()``. If you call that method in
your custom ViewHelpers you should use
``AbstractFormFieldViewHelper::getValueAttribute()`` instead and call
``AbstractFormFieldViewHelper::addAdditionalIdentityPropertiesIfNeeded()``
explicitly if the ViewHelper might be bound to (sub)entities.

The default usage of getValueAttribute() not respect the submitted form data, because not every viewhelper need
this feature. But you can enable the usage of the form data by setting the
AbstractFormFieldViewHelper::respectSubmittedDataValue to TRUE.

Change-Id: I05d9996df0a5594390ff7a005bbee7f2ceeb06bc
Resolves: #66588
Related: #34186
Releases: master
Reviewed-on: http://review.typo3.org/42298
Reviewed-by: Sascha Wilking <sascha.wilking@hmmh.de>
Tested-by: Sascha Wilking <sascha.wilking@hmmh.de>
Reviewed-by: Susanne Moog <typo3@susannemoog.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
17 files changed:
typo3/sysext/core/Documentation/Changelog/master/Deprecation-66588-POSTDataInSelectviewhelperShouldHaveHigherPriorityThanValueValue.rst [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Form/AbstractFormFieldViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/ButtonViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/CheckboxViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/HiddenViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/PasswordViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/RadioViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/SelectViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/SubmitViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/TextareaViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/TextfieldViewHelper.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/AbstractFormFieldViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/CheckboxViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/HiddenViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/RadioViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/SelectViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/FormViewHelperTest.php

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-66588-POSTDataInSelectviewhelperShouldHaveHigherPriorityThanValueValue.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-66588-POSTDataInSelectviewhelperShouldHaveHigherPriorityThanValueValue.rst
new file mode 100644 (file)
index 0000000..8ea4acf
--- /dev/null
@@ -0,0 +1,36 @@
+==================================================================================================
+Deprecation: #66588 - POST Data in selectviewhelper should have higher priority than "value" value
+==================================================================================================
+
+Description
+===========
+
+Submitted form data has precedence over value argument
+
+This adjusts the behavior of all Form ViewHelpers so that any
+submitted value is redisplayed even if a "value" argument has been
+specified.
+
+The issue with this, however, was that upon re-display of the form due
+to property-mapping or validation errors the value argument had
+precedence over the previously submitted value.
+
+
+Impact
+======
+
+This is a breaking change if you expect the previous behavior of form
+ViewHelpers always being pre-populated with the specified value
+attribute / bound object property even when re-displaying the form upon
+validation errors.
+
+Besides this change deprecates
+``AbstractFormFieldViewHelper::getValue()``. If you call that method in
+your custom ViewHelpers you should use
+``AbstractFormFieldViewHelper::getValueAttribute()`` instead and call
+``AbstractFormFieldViewHelper::addAdditionalIdentityPropertiesIfNeeded()``
+explicitly if the ViewHelper might be bound to (sub)entities.
+
+The default usage of getValueAttribute() not respect the submitted form data, because not every viewhelper need
+this feature. But you can enable the usage of the form data by setting the
+AbstractFormFieldViewHelper::respectSubmittedDataValue to TRUE.
\ No newline at end of file
index baefad2..2f86dda 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+
 namespace TYPO3\CMS\Fluid\ViewHelpers\Form;
 
 /*                                                                        *
@@ -20,6 +21,8 @@ namespace TYPO3\CMS\Fluid\ViewHelpers\Form;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
+
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Reflection\ObjectAccess;
 
 /**
@@ -39,6 +42,11 @@ abstract class AbstractFormFieldViewHelper extends AbstractFormViewHelper {
        protected $configurationManager;
 
        /**
+        * @var boolean
+        */
+       protected $respectSubmittedDataValue = FALSE;
+
+       /**
         * Initialize arguments.
         *
         * @return void
@@ -48,7 +56,29 @@ abstract class AbstractFormFieldViewHelper extends AbstractFormViewHelper {
                parent::initializeArguments();
                $this->registerArgument('name', 'string', 'Name of input tag');
                $this->registerArgument('value', 'mixed', 'Value of input tag');
-               $this->registerArgument('property', 'string', 'Name of Object Property. If used in conjunction with <f:form object="...">, "name" and "value" properties will be ignored.');
+               $this->registerArgument(
+                       'property', 'string',
+                       'Name of Object Property. If used in conjunction with <f:form object="...">, "name" and "value" properties will be ignored.'
+               );
+       }
+
+       /**
+        * Getting the current configuration for respectSubmittedDataValue.
+        *
+        * @return boolean
+        */
+       public function getRespectSubmittedDataValue() {
+               return $this->respectSubmittedDataValue;
+       }
+
+       /**
+        * Define respectSubmittedDataValue to enable or disable the usage of the submitted values in the viewhelper.
+        *
+        * @param boolean $respectSubmittedDataValue
+        * @return void
+        */
+       public function setRespectSubmittedDataValue($respectSubmittedDataValue) {
+               $this->respectSubmittedDataValue = $respectSubmittedDataValue;
        }
 
        /**
@@ -80,7 +110,9 @@ abstract class AbstractFormFieldViewHelper extends AbstractFormViewHelper {
         */
        protected function getNameWithoutPrefix() {
                if ($this->isObjectAccessorMode()) {
-                       $formObjectName = $this->viewHelperVariableContainer->get(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObjectName');
+                       $formObjectName = $this->viewHelperVariableContainer->get(
+                               \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObjectName'
+                       );
                        if (!empty($formObjectName)) {
                                $propertySegments = explode('.', $this->arguments['property']);
                                $propertyPath = '';
@@ -107,11 +139,13 @@ abstract class AbstractFormFieldViewHelper extends AbstractFormViewHelper {
         * Get the value of this form element.
         * Either returns arguments['value'], or the correct value for Object Access.
         *
+        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
         * @param bool $convertObjects whether or not to convert objects to identifiers
         * @return mixed Value
         */
        protected function getValue($convertObjects = TRUE) {
                $value = NULL;
+               GeneralUtility::logDeprecatedFunction();
 
                if ($this->hasArgument('value')) {
                        $value = $this->arguments['value'];
@@ -131,6 +165,60 @@ abstract class AbstractFormFieldViewHelper extends AbstractFormViewHelper {
        }
 
        /**
+        * Returns the current value of this Form ViewHelper and converts it to an identifier string in case it's an object
+        * The value is determined as follows:
+        * * If property mapping errors occurred and the form is re-displayed, the *last submitted* value is returned
+        * * Else the bound property is returned (only in objectAccessor-mode)
+        * * As fallback the "value" argument of this ViewHelper is used
+        *
+        * Note: This method should *not* be used for form elements that must not change the value attribute, e.g. (radio) buttons and checkboxes.
+        *
+        * @return mixed Value
+        */
+       protected function getValueAttribute() {
+               $value = NULL;
+
+               if ($this->respectSubmittedDataValue) {
+                       $value = $this->getValueFromSubmittedFormData($value);
+               } elseif ($this->hasArgument('value')) {
+                       $value = $this->arguments['value'];
+               }
+
+               if (is_object($value)) {
+                       $value = $this->persistenceManager->getIdentifierByObject($value);
+               }
+               return $value;
+       }
+
+       /**
+        * If property mapping errors occurred and the form is re-displayed, the *last submitted* value is returned by this
+        * method.
+        *
+        * Note:
+        * This method should *not* be used for form elements that must not change the value attribute, e.g. (radio)
+        * buttons and checkboxes. The default behaviour is not to use this method. You need to set
+        * respectSubmittedDataValue to TRUE to enable the form data handling for the viewhelper.
+        *
+        * @param mixed $value
+        * @return mixed Value
+        */
+       protected function getValueFromSubmittedFormData($value) {
+               $submittedFormData = NULL;
+               if ($this->hasMappingErrorOccurred()) {
+                       $submittedFormData = $this->getLastSubmittedFormData();
+               }
+               if ($submittedFormData !== NULL) {
+                       $value = $submittedFormData;
+               } elseif ($this->hasArgument('value')) {
+                       $value = $this->arguments['value'];
+               } elseif ($this->isObjectAccessorMode()) {
+                       $value = $this->getPropertyValue();
+               }
+
+               return $value;
+       }
+
+       /**
         * Converts an arbitrary value to a plain value
         *
         * @param mixed $value The value to convert
@@ -163,7 +251,9 @@ abstract class AbstractFormFieldViewHelper extends AbstractFormViewHelper {
         */
        protected function getLastSubmittedFormData() {
                $propertyPath = rtrim(preg_replace('/(\\]\\[|\\[|\\])/', '.', $this->getNameWithoutPrefix()), '.');
-               $value = ObjectAccess::getPropertyPath($this->controllerContext->getRequest()->getOriginalRequest()->getArguments(), $propertyPath);
+               $value = ObjectAccess::getPropertyPath(
+                       $this->controllerContext->getRequest()->getOriginalRequest()->getArguments(), $propertyPath
+               );
                return $value;
        }
 
@@ -174,7 +264,14 @@ abstract class AbstractFormFieldViewHelper extends AbstractFormViewHelper {
         * @return void
         */
        protected function addAdditionalIdentityPropertiesIfNeeded() {
-               if (!$this->viewHelperVariableContainer->exists(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObject')) {
+               if (!$this->isObjectAccessorMode()) {
+                       return;
+               }
+
+               if (!$this->viewHelperVariableContainer->exists(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObject'
+               )
+               ) {
                        return;
                }
                $propertySegments = explode('.', $this->arguments['property']);
@@ -182,17 +279,26 @@ abstract class AbstractFormFieldViewHelper extends AbstractFormViewHelper {
                if (count($propertySegments) < 2) {
                        return;
                }
-               $formObject = $this->viewHelperVariableContainer->get(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObject');
-               $objectName = $this->viewHelperVariableContainer->get(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObjectName');
+               $formObject = $this->viewHelperVariableContainer->get(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObject'
+               );
+               $objectName = $this->viewHelperVariableContainer->get(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObjectName'
+               );
                // If count == 2 -> we need to go through the for-loop exactly once
                for ($i = 1; $i < count($propertySegments); $i++) {
                        $object = ObjectAccess::getPropertyPath($formObject, implode('.', array_slice($propertySegments, 0, $i)));
                        $objectName .= '[' . $propertySegments[($i - 1)] . ']';
                        $hiddenIdentityField = $this->renderHiddenIdentityField($object, $objectName);
                        // Add the hidden identity field to the ViewHelperVariableContainer
-                       $additionalIdentityProperties = $this->viewHelperVariableContainer->get(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'additionalIdentityProperties');
+                       $additionalIdentityProperties = $this->viewHelperVariableContainer->get(
+                               \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'additionalIdentityProperties'
+                       );
                        $additionalIdentityProperties[$objectName] = $hiddenIdentityField;
-                       $this->viewHelperVariableContainer->addOrUpdate(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'additionalIdentityProperties', $additionalIdentityProperties);
+                       $this->viewHelperVariableContainer->addOrUpdate(
+                               \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'additionalIdentityProperties',
+                               $additionalIdentityProperties
+                       );
                }
        }
 
@@ -202,10 +308,15 @@ abstract class AbstractFormFieldViewHelper extends AbstractFormViewHelper {
         * @return mixed Value
         */
        protected function getPropertyValue() {
-               if (!$this->viewHelperVariableContainer->exists(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObject')) {
+               if (!$this->viewHelperVariableContainer->exists(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObject'
+               )
+               ) {
                        return NULL;
                }
-               $formObject = $this->viewHelperVariableContainer->get(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObject');
+               $formObject = $this->viewHelperVariableContainer->get(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObject'
+               );
                $propertyName = $this->arguments['property'];
                if (is_array($formObject)) {
                        return isset($formObject[$propertyName]) ? $formObject[$propertyName] : NULL;
@@ -219,7 +330,9 @@ abstract class AbstractFormFieldViewHelper extends AbstractFormViewHelper {
         * @return bool TRUE if we should evaluate the domain object, FALSE otherwise.
         */
        protected function isObjectAccessorMode() {
-               return $this->hasArgument('property') && $this->viewHelperVariableContainer->exists(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObjectName');
+               return $this->hasArgument('property') && $this->viewHelperVariableContainer->exists(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObjectName'
+               );
        }
 
        /**
@@ -255,7 +368,9 @@ abstract class AbstractFormFieldViewHelper extends AbstractFormViewHelper {
                        return new \TYPO3\CMS\Extbase\Error\Result();
                }
                $originalRequestMappingResults = $this->getRequest()->getOriginalRequestMappingResults();
-               $formObjectName = $this->viewHelperVariableContainer->get(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObjectName');
+               $formObjectName = $this->viewHelperVariableContainer->get(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObjectName'
+               );
                return $originalRequestMappingResults->forProperty($formObjectName)->forProperty($this->arguments['property']);
        }
 
@@ -266,9 +381,14 @@ abstract class AbstractFormFieldViewHelper extends AbstractFormViewHelper {
         * @return string the hidden field.
         */
        protected function renderHiddenFieldForEmptyValue() {
-               $hiddenFieldNames = array();
-               if ($this->viewHelperVariableContainer->exists(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'renderedHiddenFields')) {
-                       $hiddenFieldNames = $this->viewHelperVariableContainer->get(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'renderedHiddenFields');
+               $hiddenFieldNames = [];
+               if ($this->viewHelperVariableContainer->exists(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'renderedHiddenFields'
+               )
+               ) {
+                       $hiddenFieldNames = $this->viewHelperVariableContainer->get(
+                               \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'renderedHiddenFields'
+                       );
                }
                $fieldName = $this->getName();
                if (substr($fieldName, -2) === '[]') {
@@ -276,7 +396,9 @@ abstract class AbstractFormFieldViewHelper extends AbstractFormViewHelper {
                }
                if (!in_array($fieldName, $hiddenFieldNames)) {
                        $hiddenFieldNames[] = $fieldName;
-                       $this->viewHelperVariableContainer->addOrUpdate(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'renderedHiddenFields', $hiddenFieldNames);
+                       $this->viewHelperVariableContainer->addOrUpdate(
+                               \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'renderedHiddenFields', $hiddenFieldNames
+                       );
                        return '<input type="hidden" name="' . htmlspecialchars($fieldName) . '" value="" />';
                }
                return '';
index de77bf5..7b63471 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+
 namespace TYPO3\CMS\Fluid\ViewHelpers\Form;
 
 /*                                                                        *
@@ -47,14 +48,33 @@ class ButtonViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFie
         */
        public function initializeArguments() {
                parent::initializeArguments();
-               $this->registerTagAttribute('autofocus', 'string', 'Specifies that a button should automatically get focus when the page loads');
-               $this->registerTagAttribute('disabled', 'string', 'Specifies that the input element should be disabled when the page loads');
+               $this->registerTagAttribute(
+                       'autofocus', 'string', 'Specifies that a button should automatically get focus when the page loads'
+               );
+               $this->registerTagAttribute(
+                       'disabled', 'string', 'Specifies that the input element should be disabled when the page loads'
+               );
                $this->registerTagAttribute('form', 'string', 'Specifies one or more forms the button belongs to');
-               $this->registerTagAttribute('formaction', 'string', 'Specifies where to send the form-data when a form is submitted. Only for type="submit"');
-               $this->registerTagAttribute('formenctype', 'string', 'Specifies how form-data should be encoded before sending it to a server. Only for type="submit" (e.g. "application/x-www-form-urlencoded", "multipart/form-data" or "text/plain")');
-               $this->registerTagAttribute('formmethod', 'string', 'Specifies how to send the form-data (which HTTP method to use). Only for type="submit" (e.g. "get" or "post")');
-               $this->registerTagAttribute('formnovalidate', 'string', 'Specifies that the form-data should not be validated on submission. Only for type="submit"');
-               $this->registerTagAttribute('formtarget', 'string', 'Specifies where to display the response after submitting the form. Only for type="submit" (e.g. "_blank", "_self", "_parent", "_top", "framename")');
+               $this->registerTagAttribute(
+                       'formaction', 'string',
+                       'Specifies where to send the form-data when a form is submitted. Only for type="submit"'
+               );
+               $this->registerTagAttribute(
+                       'formenctype', 'string',
+                       'Specifies how form-data should be encoded before sending it to a server. Only for type="submit" (e.g. "application/x-www-form-urlencoded", "multipart/form-data" or "text/plain")'
+               );
+               $this->registerTagAttribute(
+                       'formmethod', 'string',
+                       'Specifies how to send the form-data (which HTTP method to use). Only for type="submit" (e.g. "get" or "post")'
+               );
+               $this->registerTagAttribute(
+                       'formnovalidate', 'string',
+                       'Specifies that the form-data should not be validated on submission. Only for type="submit"'
+               );
+               $this->registerTagAttribute(
+                       'formtarget', 'string',
+                       'Specifies where to display the response after submitting the form. Only for type="submit" (e.g. "_blank", "_self", "_parent", "_top", "framename")'
+               );
                $this->registerUniversalTagAttributes();
        }
 
@@ -71,7 +91,7 @@ class ButtonViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFie
 
                $this->tag->addAttribute('type', $type);
                $this->tag->addAttribute('name', $name);
-               $this->tag->addAttribute('value', $this->getValue());
+               $this->tag->addAttribute('value', $this->getValueAttribute());
                $this->tag->setContent($this->renderChildren());
 
                return $this->tag->render();
index cb8686a..70c3919 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+
 namespace TYPO3\CMS\Fluid\ViewHelpers\Form;
 
 /*                                                                        *
@@ -10,6 +11,7 @@ namespace TYPO3\CMS\Fluid\ViewHelpers\Form;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
+
 /**
  * View Helper which creates a simple checkbox (<input type="checkbox">).
  *
@@ -55,8 +57,12 @@ class CheckboxViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormF
         */
        public function initializeArguments() {
                parent::initializeArguments();
-               $this->registerTagAttribute('disabled', 'string', 'Specifies that the input element should be disabled when the page loads');
-               $this->registerArgument('errorClass', 'string', 'CSS class to set if there are errors for this view helper', FALSE, 'f3-form-error');
+               $this->registerTagAttribute(
+                       'disabled', 'string', 'Specifies that the input element should be disabled when the page loads'
+               );
+               $this->registerArgument(
+                       'errorClass', 'string', 'CSS class to set if there are errors for this view helper', FALSE, 'f3-form-error'
+               );
                $this->overrideArgument('value', 'string', 'Value of input tag. Required for checkboxes', TRUE);
                $this->registerUniversalTagAttributes();
        }
@@ -74,35 +80,37 @@ class CheckboxViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormF
                $this->tag->addAttribute('type', 'checkbox');
 
                $nameAttribute = $this->getName();
-               $valueAttribute = $this->getValue();
-               if ($this->isObjectAccessorMode()) {
-                       if ($this->hasMappingErrorOccurred()) {
-                               $propertyValue = $this->getLastSubmittedFormData();
-                       } else {
-                               $propertyValue = $this->getPropertyValue();
-                       }
+               $valueAttribute = $this->getValueAttribute();
+               $propertyValue = NULL;
+               if ($this->hasMappingErrorOccurred()) {
+                       $propertyValue = $this->getLastSubmittedFormData();
+               }
+               if ($checked === NULL && $propertyValue === NULL) {
+                       $propertyValue = $this->getPropertyValue();
+               }
 
-                       if ($propertyValue instanceof \Traversable) {
-                               $propertyValue = iterator_to_array($propertyValue);
-                       }
-                       if (is_array($propertyValue)) {
-                               $propertyValue = array_map(array($this, 'convertToPlainValue'), $propertyValue);
-                               if ($checked === NULL) {
-                                       $checked = in_array($valueAttribute, $propertyValue);
-                               }
-                               $nameAttribute .= '[]';
-                       } elseif ($multiple === TRUE) {
-                               $nameAttribute .= '[]';
-                       } elseif ($checked === NULL && $propertyValue !== NULL) {
-                               $checked = (bool)$propertyValue === (bool)$valueAttribute;
+               if ($propertyValue instanceof \Traversable) {
+                       $propertyValue = iterator_to_array($propertyValue);
+               }
+               if (is_array($propertyValue)) {
+                       $propertyValue = array_map(array($this, 'convertToPlainValue'), $propertyValue);
+                       if ($checked === NULL) {
+                               $checked = in_array($valueAttribute, $propertyValue);
                        }
+                       $nameAttribute .= '[]';
+               } elseif ($multiple === TRUE) {
+                       $nameAttribute .= '[]';
+               } elseif ($propertyValue !== NULL) {
+                       $checked = (boolean) $propertyValue === (boolean) $valueAttribute;
                }
+
                $this->registerFieldNameForFormTokenGeneration($nameAttribute);
                $this->tag->addAttribute('name', $nameAttribute);
                $this->tag->addAttribute('value', $valueAttribute);
-               if ($checked) {
+               if ($checked === TRUE) {
                        $this->tag->addAttribute('checked', 'checked');
                }
+
                $this->setErrorClassAttribute();
                $hiddenField = $this->renderHiddenFieldForEmptyValue();
                return $hiddenField . $this->tag->render();
index 51781ea..304c099 100644 (file)
@@ -58,7 +58,7 @@ class HiddenViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFie
 
                $this->tag->addAttribute('type', 'hidden');
                $this->tag->addAttribute('name', $name);
-               $this->tag->addAttribute('value', $this->getValue());
+               $this->tag->addAttribute('value', $this->getValueAttribute());
 
                return $this->tag->render();
        }
index 62f24d2..2195bb0 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+
 namespace TYPO3\CMS\Fluid\ViewHelpers\Form;
 
 /*                                                                        *
@@ -40,11 +41,17 @@ class PasswordViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormF
         */
        public function initializeArguments() {
                parent::initializeArguments();
-               $this->registerTagAttribute('disabled', 'string', 'Specifies that the input element should be disabled when the page loads');
-               $this->registerTagAttribute('maxlength', 'int', 'The maxlength attribute of the input field (will not be validated)');
+               $this->registerTagAttribute(
+                       'disabled', 'string', 'Specifies that the input element should be disabled when the page loads'
+               );
+               $this->registerTagAttribute(
+                       'maxlength', 'int', 'The maxlength attribute of the input field (will not be validated)'
+               );
                $this->registerTagAttribute('readonly', 'string', 'The readonly attribute of the input field');
                $this->registerTagAttribute('size', 'int', 'The size of the input field');
-               $this->registerArgument('errorClass', 'string', 'CSS class to set if there are errors for this view helper', FALSE, 'f3-form-error');
+               $this->registerArgument(
+                       'errorClass', 'string', 'CSS class to set if there are errors for this view helper', FALSE, 'f3-form-error'
+               );
                $this->registerUniversalTagAttributes();
        }
 
@@ -57,11 +64,13 @@ class PasswordViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormF
        public function render() {
                $name = $this->getName();
                $this->registerFieldNameForFormTokenGeneration($name);
+               $this->setRespectSubmittedDataValue(TRUE);
 
                $this->tag->addAttribute('type', 'password');
                $this->tag->addAttribute('name', $name);
-               $this->tag->addAttribute('value', $this->getValue());
+               $this->tag->addAttribute('value', $this->getValueAttribute());
 
+               $this->addAdditionalIdentityPropertiesIfNeeded();
                $this->setErrorClassAttribute();
 
                return $this->tag->render();
index 749bed0..ca8502a 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+
 namespace TYPO3\CMS\Fluid\ViewHelpers\Form;
 
 /*                                                                        *
@@ -58,8 +59,12 @@ class RadioViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFiel
         */
        public function initializeArguments() {
                parent::initializeArguments();
-               $this->registerTagAttribute('disabled', 'string', 'Specifies that the input element should be disabled when the page loads');
-               $this->registerArgument('errorClass', 'string', 'CSS class to set if there are errors for this view helper', FALSE, 'f3-form-error');
+               $this->registerTagAttribute(
+                       'disabled', 'string', 'Specifies that the input element should be disabled when the page loads'
+               );
+               $this->registerArgument(
+                       'errorClass', 'string', 'CSS class to set if there are errors for this view helper', FALSE, 'f3-form-error'
+               );
                $this->overrideArgument('value', 'string', 'Value of input tag. Required for radio buttons', TRUE);
                $this->registerUniversalTagAttributes();
        }
@@ -75,13 +80,17 @@ class RadioViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFiel
                $this->tag->addAttribute('type', 'radio');
 
                $nameAttribute = $this->getName();
-               $valueAttribute = $this->getValue();
-               if ($checked === NULL && $this->isObjectAccessorMode()) {
-                       if ($this->hasMappingErrorOccurred()) {
-                               $propertyValue = $this->getLastSubmittedFormData();
-                       } else {
-                               $propertyValue = $this->getPropertyValue();
-                       }
+               $valueAttribute = $this->getValueAttribute();
+
+               $propertyValue = NULL;
+               if ($this->hasMappingErrorOccurred()) {
+                       $propertyValue = $this->getLastSubmittedFormData();
+               }
+               if ($checked === NULL && $propertyValue === NULL) {
+                       $propertyValue = $this->getPropertyValue();
+               }
+
+               if ($propertyValue !== NULL) {
 
                        // no type-safe comparison by intention
                        $checked = $propertyValue == $valueAttribute;
@@ -90,7 +99,7 @@ class RadioViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFiel
                $this->registerFieldNameForFormTokenGeneration($nameAttribute);
                $this->tag->addAttribute('name', $nameAttribute);
                $this->tag->addAttribute('value', $valueAttribute);
-               if ($checked) {
+               if ($checked === TRUE) {
                        $this->tag->addAttribute('checked', 'checked');
                }
 
index 6c992c3..d4e347a 100644 (file)
@@ -106,6 +106,7 @@ class SelectViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFie
                        $options = array('' => '');
                }
                $this->tag->setContent($this->renderOptionTags($options));
+               $this->addAdditionalIdentityPropertiesIfNeeded();
                $this->setErrorClassAttribute();
                $content = '';
                // register field name for token generation.
@@ -224,7 +225,8 @@ class SelectViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFie
         * @return mixed value string or an array of strings
         */
        protected function getSelectedValue() {
-               $value = $this->getValue();
+               $this->setRespectSubmittedDataValue(TRUE);
+               $value = $this->getValueAttribute();
                if (!is_array($value) && !$value instanceof \Traversable) {
                        return $this->getOptionValueScalar($value);
                }
index c79e088..991075c 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+
 namespace TYPO3\CMS\Fluid\ViewHelpers\Form;
 
 /*                                                                        *
@@ -47,7 +48,9 @@ class SubmitViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFie
         */
        public function initializeArguments() {
                parent::initializeArguments();
-               $this->registerTagAttribute('disabled', 'string', 'Specifies that the input element should be disabled when the page loads');
+               $this->registerTagAttribute(
+                       'disabled', 'string', 'Specifies that the input element should be disabled when the page loads'
+               );
                $this->registerUniversalTagAttributes();
        }
 
@@ -63,9 +66,8 @@ class SubmitViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFie
 
                $this->tag->addAttribute('type', 'submit');
                $this->tag->addAttribute('name', $name);
-               $this->tag->addAttribute('value', $this->getValue());
+               $this->tag->addAttribute('value', $this->getValueAttribute());
 
                return $this->tag->render();
        }
-
 }
index 787c603..868621c 100644 (file)
@@ -59,11 +59,13 @@ class TextareaViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormF
        public function render() {
                $name = $this->getName();
                $this->registerFieldNameForFormTokenGeneration($name);
+               $this->setRespectSubmittedDataValue(TRUE);
 
                $this->tag->forceClosingTag(TRUE);
                $this->tag->addAttribute('name', $name);
-               $this->tag->setContent(htmlspecialchars($this->getValue()));
+               $this->tag->setContent(htmlspecialchars($this->getValueAttribute()));
 
+               $this->addAdditionalIdentityPropertiesIfNeeded();
                $this->setErrorClassAttribute();
 
                return $this->tag->render();
index 22f6c9d..7abe800 100644 (file)
@@ -62,11 +62,12 @@ class TextfieldViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractForm
        public function render($required = NULL, $type = 'text') {
                $name = $this->getName();
                $this->registerFieldNameForFormTokenGeneration($name);
+               $this->setRespectSubmittedDataValue(TRUE);
 
                $this->tag->addAttribute('type', $type);
                $this->tag->addAttribute('name', $name);
 
-               $value = $this->getValue();
+               $value = $this->getValueAttribute();
 
                if ($value !== NULL) {
                        $this->tag->addAttribute('value', $value);
@@ -76,6 +77,7 @@ class TextfieldViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractForm
                        $this->tag->addAttribute('required', 'required');
                }
 
+               $this->addAdditionalIdentityPropertiesIfNeeded();
                $this->setErrorClassAttribute();
 
                return $this->tag->render();
index 21039db..09b1ef6 100644 (file)
@@ -15,22 +15,52 @@ namespace TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form;
  * Test for the Abstract Form view helper
  */
 class AbstractFormFieldViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\FormFieldViewHelperBaseTestcase {
+       /**
+        * @test
+        */
+       public function getRespectSubmittedDataValueInitiallyReturnsFalse() {
+               $formViewHelper = $this->getAccessibleMock(
+                       \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, ['isObjectAccessorMode'], [], '',
+                       FALSE
+               );
+               $this->injectDependenciesIntoViewHelper($formViewHelper);
+
+               $this->assertFalse($formViewHelper->_call('getRespectSubmittedDataValue'));
+       }
+
+       /**
+        * @test
+        */
+       public function setRespectSubmittedDataValueToTrue() {
+               $formViewHelper = $this->getAccessibleMock(
+                       \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, ['isObjectAccessorMode'], [], '',
+                       FALSE
+               );
+               $this->injectDependenciesIntoViewHelper($formViewHelper);
+
+               $formViewHelper->_set('respectSubmittedDataValue', TRUE);
+               $this->assertTrue($formViewHelper->_call('getRespectSubmittedDataValue'));
+       }
 
        /**
         * @test
         */
        public function ifAnAttributeValueIsAnObjectMaintainedByThePersistenceManagerItIsConvertedToAUID() {
                $mockPersistenceManager = $this->getMock(\TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface::class);
-               $mockPersistenceManager->expects($this->any())->method('getIdentifierByObject')->will($this->returnValue('6f487e40-4483-11de-8a39-0800200c9a66'));
+               $mockPersistenceManager->expects($this->any())->method('getIdentifierByObject')->will(
+                       $this->returnValue('6f487e40-4483-11de-8a39-0800200c9a66')
+               );
 
                $object = $this->getMock(\TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\Fixtures\EmptyClass::class);
                $object->expects($this->any())->method('FLOW3_Persistence_isNew')->will($this->returnValue(FALSE));
 
-               $formViewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, array('dummy'), array(), '', FALSE);
+               $formViewHelper = $this->getAccessibleMock(
+                       \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, ['dummy'], [], '', FALSE
+               );
                $this->injectDependenciesIntoViewHelper($formViewHelper);
                $formViewHelper->_set('persistenceManager', $mockPersistenceManager);
 
-               $arguments = array('name' => 'foo', 'value' => $object, 'property' => NULL);
+               $arguments = ['name' => 'foo', 'value' => $object, 'property' => NULL];
                $formViewHelper->_set('arguments', $arguments);
                $formViewHelper->expects($this->any())->method('isObjectAccessorMode')->will($this->returnValue(FALSE));
 
@@ -42,15 +72,24 @@ class AbstractFormFieldViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHe
         * @test
         */
        public function getNameBuildsNameFromFieldNamePrefixFormObjectNameAndPropertyIfInObjectAccessorMode() {
-               $formViewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, array('isObjectAccessorMode'), array(), '', FALSE);
+               $formViewHelper = $this->getAccessibleMock(
+                       \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, ['isObjectAccessorMode'], [], '',
+                       FALSE
+               );
                $this->injectDependenciesIntoViewHelper($formViewHelper);
 
                $formViewHelper->expects($this->any())->method('isObjectAccessorMode')->will($this->returnValue(TRUE));
-               $this->viewHelperVariableContainer->expects($this->at(0))->method('get')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObjectName')->will($this->returnValue('myObjectName'));
-               $this->viewHelperVariableContainer->expects($this->at(1))->method('exists')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'fieldNamePrefix')->will($this->returnValue(TRUE));
-               $this->viewHelperVariableContainer->expects($this->at(2))->method('get')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'fieldNamePrefix')->will($this->returnValue('formPrefix'));
-
-               $arguments = array('name' => 'fieldName', 'value' => 'fieldValue', 'property' => 'bla');
+               $this->viewHelperVariableContainer->expects($this->at(0))->method('get')->with(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObjectName'
+               )->will($this->returnValue('myObjectName'));
+               $this->viewHelperVariableContainer->expects($this->at(1))->method('exists')->with(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'fieldNamePrefix'
+               )->will($this->returnValue(TRUE));
+               $this->viewHelperVariableContainer->expects($this->at(2))->method('get')->with(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'fieldNamePrefix'
+               )->will($this->returnValue('formPrefix'));
+
+               $arguments = ['name' => 'fieldName', 'value' => 'fieldValue', 'property' => 'bla'];
                $formViewHelper->_set('arguments', $arguments);
                $expected = 'formPrefix[myObjectName][bla]';
                $actual = $formViewHelper->_call('getName');
@@ -61,15 +100,24 @@ class AbstractFormFieldViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHe
         * @test
         */
        public function getNameBuildsNameFromFieldNamePrefixFormObjectNameAndHierarchicalPropertyIfInObjectAccessorMode() {
-               $formViewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, array('isObjectAccessorMode'), array(), '', FALSE);
+               $formViewHelper = $this->getAccessibleMock(
+                       \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, ['isObjectAccessorMode'], [], '',
+                       FALSE
+               );
                $this->injectDependenciesIntoViewHelper($formViewHelper);
 
                $formViewHelper->expects($this->any())->method('isObjectAccessorMode')->will($this->returnValue(TRUE));
-               $this->viewHelperVariableContainer->expects($this->at(0))->method('get')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObjectName')->will($this->returnValue('myObjectName'));
-               $this->viewHelperVariableContainer->expects($this->at(1))->method('exists')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'fieldNamePrefix')->will($this->returnValue(TRUE));
-               $this->viewHelperVariableContainer->expects($this->at(2))->method('get')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'fieldNamePrefix')->will($this->returnValue('formPrefix'));
-
-               $arguments = array('name' => 'fieldName', 'value' => 'fieldValue', 'property' => 'bla.blubb');
+               $this->viewHelperVariableContainer->expects($this->at(0))->method('get')->with(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObjectName'
+               )->will($this->returnValue('myObjectName'));
+               $this->viewHelperVariableContainer->expects($this->at(1))->method('exists')->with(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'fieldNamePrefix'
+               )->will($this->returnValue(TRUE));
+               $this->viewHelperVariableContainer->expects($this->at(2))->method('get')->with(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'fieldNamePrefix'
+               )->will($this->returnValue('formPrefix'));
+
+               $arguments = ['name' => 'fieldName', 'value' => 'fieldValue', 'property' => 'bla.blubb'];
                $formViewHelper->_set('arguments', $arguments);
                $expected = 'formPrefix[myObjectName][bla][blubb]';
                $actual = $formViewHelper->_call('getName');
@@ -79,16 +127,26 @@ class AbstractFormFieldViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHe
        /**
         * @test
         */
-       public function getNameBuildsNameFromFieldNamePrefixAndPropertyIfInObjectAccessorModeAndNoFormObjectNameIsSpecified() {
-               $formViewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, array('isObjectAccessorMode'), array(), '', FALSE);
+       public function getNameBuildsNameFromFieldNamePrefixAndPropertyIfInObjectAccessorModeAndNoFormObjectNameIsSpecified(
+       ) {
+               $formViewHelper = $this->getAccessibleMock(
+                       \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, ['isObjectAccessorMode'], [], '',
+                       FALSE
+               );
                $this->injectDependenciesIntoViewHelper($formViewHelper);
 
                $formViewHelper->expects($this->any())->method('isObjectAccessorMode')->will($this->returnValue(TRUE));
-               $this->viewHelperVariableContainer->expects($this->at(0))->method('get')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObjectName')->will($this->returnValue(NULL));
-               $this->viewHelperVariableContainer->expects($this->at(1))->method('exists')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'fieldNamePrefix')->will($this->returnValue(TRUE));
-               $this->viewHelperVariableContainer->expects($this->at(2))->method('get')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'fieldNamePrefix')->will($this->returnValue('formPrefix'));
-
-               $arguments = array('name' => 'fieldName', 'value' => 'fieldValue', 'property' => 'bla');
+               $this->viewHelperVariableContainer->expects($this->at(0))->method('get')->with(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObjectName'
+               )->will($this->returnValue(NULL));
+               $this->viewHelperVariableContainer->expects($this->at(1))->method('exists')->with(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'fieldNamePrefix'
+               )->will($this->returnValue(TRUE));
+               $this->viewHelperVariableContainer->expects($this->at(2))->method('get')->with(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'fieldNamePrefix'
+               )->will($this->returnValue('formPrefix'));
+
+               $arguments = ['name' => 'fieldName', 'value' => 'fieldValue', 'property' => 'bla'];
                $formViewHelper->_set('arguments', $arguments);
                $expected = 'formPrefix[bla]';
                $actual = $formViewHelper->_call('getName');
@@ -99,14 +157,21 @@ class AbstractFormFieldViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHe
         * @test
         */
        public function getNameBuildsNameFromFieldNamePrefixAndFieldNameIfNotInObjectAccessorMode() {
-               $formViewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, array('isObjectAccessorMode'), array(), '', FALSE);
+               $formViewHelper = $this->getAccessibleMock(
+                       \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, ['isObjectAccessorMode'], [], '',
+                       FALSE
+               );
                $this->injectDependenciesIntoViewHelper($formViewHelper);
 
                $formViewHelper->expects($this->any())->method('isObjectAccessorMode')->will($this->returnValue(FALSE));
-               $this->viewHelperVariableContainer->expects($this->at(0))->method('exists')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'fieldNamePrefix')->will($this->returnValue(TRUE));
-               $this->viewHelperVariableContainer->expects($this->at(1))->method('get')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'fieldNamePrefix')->will($this->returnValue('formPrefix'));
-
-               $arguments = array('name' => 'fieldName', 'value' => 'fieldValue', 'property' => 'bla');
+               $this->viewHelperVariableContainer->expects($this->at(0))->method('exists')->with(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'fieldNamePrefix'
+               )->will($this->returnValue(TRUE));
+               $this->viewHelperVariableContainer->expects($this->at(1))->method('get')->with(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'fieldNamePrefix'
+               )->will($this->returnValue('formPrefix'));
+
+               $arguments = ['name' => 'fieldName', 'value' => 'fieldValue', 'property' => 'bla'];
                $formViewHelper->_set('arguments', $arguments);
                $expected = 'formPrefix[fieldName]';
                $actual = $formViewHelper->_call('getName');
@@ -117,17 +182,24 @@ class AbstractFormFieldViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHe
         * @test
         */
        public function getValueBuildsValueFromPropertyAndFormObjectIfInObjectAccessorMode() {
-               $formViewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, array('isObjectAccessorMode', 'addAdditionalIdentityPropertiesIfNeeded'), array(), '', FALSE);
+               $formViewHelper = $this->getAccessibleMock(
+                       \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class,
+                       ['isObjectAccessorMode', 'addAdditionalIdentityPropertiesIfNeeded'], [], '', FALSE
+               );
                $this->injectDependenciesIntoViewHelper($formViewHelper);
 
                $mockObject = new \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\Fixtures\ClassWithTwoGetters();
 
                $formViewHelper->expects($this->any())->method('isObjectAccessorMode')->will($this->returnValue(TRUE));
                $formViewHelper->expects($this->once())->method('addAdditionalIdentityPropertiesIfNeeded');
-               $this->viewHelperVariableContainer->expects($this->atLeastOnce())->method('get')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObject')->will($this->returnValue($mockObject));
-               $this->viewHelperVariableContainer->expects($this->atLeastOnce())->method('exists')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObject')->will($this->returnValue(TRUE));
-
-               $arguments = array('name' => NULL, 'value' => NULL, 'property' => 'value.something');
+               $this->viewHelperVariableContainer->expects($this->atLeastOnce())->method('get')->with(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObject'
+               )->will($this->returnValue($mockObject));
+               $this->viewHelperVariableContainer->expects($this->atLeastOnce())->method('exists')->with(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObject'
+               )->will($this->returnValue(TRUE));
+
+               $arguments = ['name' => NULL, 'value' => NULL, 'property' => 'value.something'];
                $formViewHelper->_set('arguments', $arguments);
                $expected = 'MyString';
                $actual = $formViewHelper->_call('getValue');
@@ -138,11 +210,14 @@ class AbstractFormFieldViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHe
         * @test
         */
        public function getValueReturnsNullIfNotInObjectAccessorModeAndValueArgumentIsNoSet() {
-               $formViewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, array('isObjectAccessorMode'), array(), '', FALSE);
+               $formViewHelper = $this->getAccessibleMock(
+                       \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, ['isObjectAccessorMode'], [], '',
+                       FALSE
+               );
                $this->injectDependenciesIntoViewHelper($formViewHelper);
                $formViewHelper->expects($this->any())->method('isObjectAccessorMode')->will($this->returnValue(FALSE));
 
-               $mockArguments = array();
+               $mockArguments = [];
                $formViewHelper->_set('arguments', $mockArguments);
 
                $this->assertNull($formViewHelper->_call('getValue'));
@@ -152,11 +227,14 @@ class AbstractFormFieldViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHe
         * @test
         */
        public function getValueReturnsValueArgumentIfSpecified() {
-               $formViewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, array('isObjectAccessorMode'), array(), '', FALSE);
+               $formViewHelper = $this->getAccessibleMock(
+                       \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, ['isObjectAccessorMode'], [], '',
+                       FALSE
+               );
                $formViewHelper->expects($this->any())->method('isObjectAccessorMode')->will($this->returnValue(FALSE));
                $this->injectDependenciesIntoViewHelper($formViewHelper);
 
-               $mockArguments = array('value' => 'someValue');
+               $mockArguments = ['value' => 'someValue'];
                $formViewHelper->_set('arguments', $mockArguments);
 
                $this->assertEquals('someValue', $formViewHelper->_call('getValue'));
@@ -169,14 +247,19 @@ class AbstractFormFieldViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHe
                $mockObject = $this->getMock('stdClass');
 
                $mockPersistenceManager = $this->getMock(\TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface::class);
-               $mockPersistenceManager->expects($this->atLeastOnce())->method('getIdentifierByObject')->with($mockObject)->will($this->returnValue('6f487e40-4483-11de-8a39-0800200c9a66'));
-
-               $formViewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, array('isObjectAccessorMode'), array(), '', FALSE);
+               $mockPersistenceManager->expects($this->atLeastOnce())->method('getIdentifierByObject')->with(
+                       $mockObject
+               )->will($this->returnValue('6f487e40-4483-11de-8a39-0800200c9a66'));
+
+               $formViewHelper = $this->getAccessibleMock(
+                       \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, ['isObjectAccessorMode'], [], '',
+                       FALSE
+               );
                $formViewHelper->expects($this->any())->method('isObjectAccessorMode')->will($this->returnValue(FALSE));
                $this->injectDependenciesIntoViewHelper($formViewHelper);
                $formViewHelper->_set('persistenceManager', $mockPersistenceManager);
 
-               $mockArguments = array('value' => $mockObject);
+               $mockArguments = ['value' => $mockObject];
                $formViewHelper->_set('arguments', $mockArguments);
 
                $this->assertSame('6f487e40-4483-11de-8a39-0800200c9a66', $formViewHelper->_call('getValue'));
@@ -189,14 +272,19 @@ class AbstractFormFieldViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHe
                $mockObject = $this->getMock('stdClass');
 
                $mockPersistenceManager = $this->getMock(\TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface::class);
-               $mockPersistenceManager->expects($this->any())->method('getIdentifierByObject')->will($this->returnValue('6f487e40-4483-11de-8a39-0800200c9a66'));
-
-               $formViewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, array('isObjectAccessorMode'), array(), '', FALSE);
+               $mockPersistenceManager->expects($this->any())->method('getIdentifierByObject')->will(
+                       $this->returnValue('6f487e40-4483-11de-8a39-0800200c9a66')
+               );
+
+               $formViewHelper = $this->getAccessibleMock(
+                       \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, ['isObjectAccessorMode'], [], '',
+                       FALSE
+               );
                $formViewHelper->expects($this->any())->method('isObjectAccessorMode')->will($this->returnValue(FALSE));
                $this->injectDependenciesIntoViewHelper($formViewHelper);
                $formViewHelper->_set('persistenceManager', $mockPersistenceManager);
 
-               $mockArguments = array('value' => $mockObject);
+               $mockArguments = ['value' => $mockObject];
                $formViewHelper->_set('arguments', $mockArguments);
 
                $this->assertSame($mockObject, $formViewHelper->_call('getValue', FALSE));
@@ -206,15 +294,19 @@ class AbstractFormFieldViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHe
         * @test
         */
        public function isObjectAccessorModeReturnsTrueIfPropertyIsSetAndFormObjectIsGiven() {
-               $formViewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, array('dummy'), array(), '', FALSE);
+               $formViewHelper = $this->getAccessibleMock(
+                       \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, ['dummy'], [], '', FALSE
+               );
                $this->injectDependenciesIntoViewHelper($formViewHelper);
 
-               $this->viewHelperVariableContainer->expects($this->once())->method('exists')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObjectName')->will($this->returnValue(TRUE));
+               $this->viewHelperVariableContainer->expects($this->once())->method('exists')->with(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObjectName'
+               )->will($this->returnValue(TRUE));
 
-               $formViewHelper->_set('arguments', array('name' => NULL, 'value' => NULL, 'property' => 'bla'));
+               $formViewHelper->_set('arguments', ['name' => NULL, 'value' => NULL, 'property' => 'bla']);
                $this->assertTrue($formViewHelper->_call('isObjectAccessorMode'));
 
-               $formViewHelper->_set('arguments', array('name' => NULL, 'value' => NULL, 'property' => NULL));
+               $formViewHelper->_set('arguments', ['name' => NULL, 'value' => NULL, 'property' => NULL]);
                $this->assertFalse($formViewHelper->_call('isObjectAccessorMode'));
        }
 
@@ -222,10 +314,15 @@ class AbstractFormFieldViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHe
         * @test
         */
        public function addAdditionalIdentityPropertiesIfNeededDoesNotCreateAnythingIfPropertyIsWithoutDot() {
-               $formFieldViewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, array('renderHiddenIdentityField'), array(), '', FALSE);
+               $formFieldViewHelper = $this->getAccessibleMock(
+                       \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, ['renderHiddenIdentityField'], [], '',
+                       FALSE
+               );
                $this->injectDependenciesIntoViewHelper($formFieldViewHelper);
-               $arguments = array('property' => 'simple');
-               $formFieldViewHelper->expects($this->any())->method('renderHiddenIdentityField')->will($this->throwException(new \Exception('Should not be executed!!!')));
+               $arguments = ['property' => 'simple'];
+               $formFieldViewHelper->expects($this->any())->method('renderHiddenIdentityField')->will(
+                       $this->throwException(new \Exception('Should not be executed!!!'))
+               );
                $formFieldViewHelper->_set('arguments', $arguments);
                $formFieldViewHelper->_call('addAdditionalIdentityPropertiesIfNeeded');
        }
@@ -239,15 +336,29 @@ class AbstractFormFieldViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHe
                $objectName = 'myObject';
                $expectedProperty = 'myObject[value]';
 
-               $formFieldViewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, array('renderHiddenIdentityField'), array(), '', FALSE);
+               $formFieldViewHelper = $this->getAccessibleMock(
+                       \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class,
+                       ['renderHiddenIdentityField', 'isObjectAccessorMode'], [], '', FALSE
+               );
                $this->injectDependenciesIntoViewHelper($formFieldViewHelper);
-               $arguments = array('property' => $property);
+               $arguments = ['property' => $property];
                $formFieldViewHelper->_set('arguments', $arguments);
-               $this->viewHelperVariableContainer->expects($this->at(0))->method('exists')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObject')->will($this->returnValue(TRUE));
-               $this->viewHelperVariableContainer->expects($this->at(1))->method('get')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObject')->will($this->returnValue($mockFormObject));
-               $this->viewHelperVariableContainer->expects($this->at(2))->method('get')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObjectName')->will($this->returnValue($objectName));
-
-               $formFieldViewHelper->expects($this->once())->method('renderHiddenIdentityField')->with($mockFormObject, $expectedProperty);
+               $formFieldViewHelper->expects($this->atLeastOnce())->method('isObjectAccessorMode')->will(
+                       $this->returnValue(TRUE)
+               );
+               $this->viewHelperVariableContainer->expects($this->at(0))->method('exists')->with(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObject'
+               )->will($this->returnValue(TRUE));
+               $this->viewHelperVariableContainer->expects($this->at(1))->method('get')->with(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObject'
+               )->will($this->returnValue($mockFormObject));
+               $this->viewHelperVariableContainer->expects($this->at(2))->method('get')->with(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObjectName'
+               )->will($this->returnValue($objectName));
+
+               $formFieldViewHelper->expects($this->once())->method('renderHiddenIdentityField')->with(
+                       $mockFormObject, $expectedProperty
+               );
 
                $formFieldViewHelper->_call('addAdditionalIdentityPropertiesIfNeeded');
        }
@@ -255,23 +366,40 @@ class AbstractFormFieldViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHe
        /**
         * @test
         */
-       public function addAdditionalIdentityPropertiesIfNeededCallsRenderIdentityFieldWithTheRightParametersWithMoreHierarchyLevels() {
+       public function addAdditionalIdentityPropertiesIfNeededCallsRenderIdentityFieldWithTheRightParametersWithMoreHierarchyLevels(
+       ) {
                $mockFormObject = new \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\Fixtures\ClassWithTwoGetters();
                $property = 'value.value.something';
                $objectName = 'myObject';
                $expectedProperty1 = 'myObject[value]';
                $expectedProperty2 = 'myObject[value][value]';
 
-               $formFieldViewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, array('renderHiddenIdentityField'), array(), '', FALSE);
+               $formFieldViewHelper = $this->getAccessibleMock(
+                       \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class,
+                       ['renderHiddenIdentityField', 'isObjectAccessorMode'], [], '', FALSE
+               );
                $this->injectDependenciesIntoViewHelper($formFieldViewHelper);
-               $arguments = array('property' => $property);
+               $arguments = ['property' => $property];
                $formFieldViewHelper->_set('arguments', $arguments);
-               $this->viewHelperVariableContainer->expects($this->at(0))->method('exists')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObject')->will($this->returnValue(TRUE));
-               $this->viewHelperVariableContainer->expects($this->at(1))->method('get')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObject')->will($this->returnValue($mockFormObject));
-               $this->viewHelperVariableContainer->expects($this->at(2))->method('get')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObjectName')->will($this->returnValue($objectName));
-
-               $formFieldViewHelper->expects($this->at(0))->method('renderHiddenIdentityField')->with($mockFormObject, $expectedProperty1);
-               $formFieldViewHelper->expects($this->at(1))->method('renderHiddenIdentityField')->with($mockFormObject, $expectedProperty2);
+               $formFieldViewHelper->expects($this->atLeastOnce())->method('isObjectAccessorMode')->will(
+                       $this->returnValue(TRUE)
+               );
+               $this->viewHelperVariableContainer->expects($this->at(0))->method('exists')->with(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObject'
+               )->will($this->returnValue(TRUE));
+               $this->viewHelperVariableContainer->expects($this->at(1))->method('get')->with(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObject'
+               )->will($this->returnValue($mockFormObject));
+               $this->viewHelperVariableContainer->expects($this->at(2))->method('get')->with(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formObjectName'
+               )->will($this->returnValue($objectName));
+
+               $formFieldViewHelper->expects($this->at(1))->method('renderHiddenIdentityField')->with(
+                       $mockFormObject, $expectedProperty1
+               );
+               $formFieldViewHelper->expects($this->at(2))->method('renderHiddenIdentityField')->with(
+                       $mockFormObject, $expectedProperty2
+               );
 
                $formFieldViewHelper->_call('addAdditionalIdentityPropertiesIfNeeded');
        }
@@ -280,11 +408,17 @@ class AbstractFormFieldViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHe
         * @test
         */
        public function renderHiddenFieldForEmptyValueRendersHiddenFieldIfItHasNotBeenRenderedBefore() {
-               $formViewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, array('getName'), array(), '', FALSE);
+               $formViewHelper = $this->getAccessibleMock(
+                       \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, ['getName'], [], '', FALSE
+               );
                $this->injectDependenciesIntoViewHelper($formViewHelper);
                $formViewHelper->expects($this->any())->method('getName')->will($this->returnValue('SomeFieldName'));
-               $this->viewHelperVariableContainer->expects($this->at(0))->method('exists')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'renderedHiddenFields')->will($this->returnValue(TRUE));
-               $this->viewHelperVariableContainer->expects($this->at(1))->method('get')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'renderedHiddenFields')->will($this->returnValue(array()));
+               $this->viewHelperVariableContainer->expects($this->at(0))->method('exists')->with(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'renderedHiddenFields'
+               )->will($this->returnValue(TRUE));
+               $this->viewHelperVariableContainer->expects($this->at(1))->method('get')->with(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'renderedHiddenFields'
+               )->will($this->returnValue([]));
                $expected = '<input type="hidden" name="SomeFieldName" value="" />';
                $actual = $formViewHelper->_call('renderHiddenFieldForEmptyValue');
                $this->assertEquals($expected, $actual);
@@ -294,12 +428,20 @@ class AbstractFormFieldViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHe
         * @test
         */
        public function renderHiddenFieldForEmptyValueAddsHiddenFieldNameToVariableContainerIfItHasBeenRendered() {
-               $formViewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, array('getName'), array(), '', FALSE);
+               $formViewHelper = $this->getAccessibleMock(
+                       \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, ['getName'], [], '', FALSE
+               );
                $this->injectDependenciesIntoViewHelper($formViewHelper);
                $formViewHelper->expects($this->any())->method('getName')->will($this->returnValue('NewFieldName'));
-               $this->viewHelperVariableContainer->expects($this->at(0))->method('exists')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'renderedHiddenFields')->will($this->returnValue(TRUE));
-               $this->viewHelperVariableContainer->expects($this->at(1))->method('get')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'renderedHiddenFields')->will($this->returnValue(array('OldFieldName')));
-               $this->viewHelperVariableContainer->expects($this->at(2))->method('addOrUpdate')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'renderedHiddenFields', array('OldFieldName', 'NewFieldName'));
+               $this->viewHelperVariableContainer->expects($this->at(0))->method('exists')->with(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'renderedHiddenFields'
+               )->will($this->returnValue(TRUE));
+               $this->viewHelperVariableContainer->expects($this->at(1))->method('get')->with(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'renderedHiddenFields'
+               )->will($this->returnValue(['OldFieldName']));
+               $this->viewHelperVariableContainer->expects($this->at(2))->method('addOrUpdate')->with(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'renderedHiddenFields', ['OldFieldName', 'NewFieldName']
+               );
                $formViewHelper->_call('renderHiddenFieldForEmptyValue');
        }
 
@@ -307,11 +449,17 @@ class AbstractFormFieldViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHe
         * @test
         */
        public function renderHiddenFieldForEmptyValueDoesNotRenderHiddenFieldIfItHasBeenRenderedBefore() {
-               $formViewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, array('getName'), array(), '', FALSE);
+               $formViewHelper = $this->getAccessibleMock(
+                       \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, ['getName'], [], '', FALSE
+               );
                $this->injectDependenciesIntoViewHelper($formViewHelper);
                $formViewHelper->expects($this->any())->method('getName')->will($this->returnValue('SomeFieldName'));
-               $this->viewHelperVariableContainer->expects($this->at(0))->method('exists')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'renderedHiddenFields')->will($this->returnValue(TRUE));
-               $this->viewHelperVariableContainer->expects($this->at(1))->method('get')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'renderedHiddenFields')->will($this->returnValue(array('SomeFieldName')));
+               $this->viewHelperVariableContainer->expects($this->at(0))->method('exists')->with(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'renderedHiddenFields'
+               )->will($this->returnValue(TRUE));
+               $this->viewHelperVariableContainer->expects($this->at(1))->method('get')->with(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'renderedHiddenFields'
+               )->will($this->returnValue(['SomeFieldName']));
                $this->viewHelperVariableContainer->expects($this->never())->method('addOrUpdate');
                $expected = '';
                $actual = $formViewHelper->_call('renderHiddenFieldForEmptyValue');
@@ -322,12 +470,22 @@ class AbstractFormFieldViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHe
         * @test
         */
        public function renderHiddenFieldForEmptyValueRemovesEmptySquareBracketsFromHiddenFieldName() {
-               $formViewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, array('getName'), array(), '', FALSE);
+               $formViewHelper = $this->getAccessibleMock(
+                       \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, ['getName'], [], '', FALSE
+               );
                $this->injectDependenciesIntoViewHelper($formViewHelper);
-               $formViewHelper->expects($this->any())->method('getName')->will($this->returnValue('SomeFieldName[WithBrackets][]'));
-               $this->viewHelperVariableContainer->expects($this->at(0))->method('exists')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'renderedHiddenFields')->will($this->returnValue(TRUE));
-               $this->viewHelperVariableContainer->expects($this->at(1))->method('get')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'renderedHiddenFields')->will($this->returnValue(array()));
-               $this->viewHelperVariableContainer->expects($this->at(2))->method('addOrUpdate')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'renderedHiddenFields', array('SomeFieldName[WithBrackets]'));
+               $formViewHelper->expects($this->any())->method('getName')->will(
+                       $this->returnValue('SomeFieldName[WithBrackets][]')
+               );
+               $this->viewHelperVariableContainer->expects($this->at(0))->method('exists')->with(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'renderedHiddenFields'
+               )->will($this->returnValue(TRUE));
+               $this->viewHelperVariableContainer->expects($this->at(1))->method('get')->with(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'renderedHiddenFields'
+               )->will($this->returnValue([]));
+               $this->viewHelperVariableContainer->expects($this->at(2))->method('addOrUpdate')->with(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'renderedHiddenFields', ['SomeFieldName[WithBrackets]']
+               );
                $expected = '<input type="hidden" name="SomeFieldName[WithBrackets]" value="" />';
                $actual = $formViewHelper->_call('renderHiddenFieldForEmptyValue');
                $this->assertEquals($expected, $actual);
@@ -337,15 +495,26 @@ class AbstractFormFieldViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHe
         * @test
         */
        public function renderHiddenFieldForEmptyValueDoesNotRemoveNonEmptySquareBracketsFromHiddenFieldName() {
-               $formViewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, array('getName'), array(), '', FALSE);
+               $formViewHelper = $this->getAccessibleMock(
+                       \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper::class, ['getName'], [], '', FALSE
+               );
                $this->injectDependenciesIntoViewHelper($formViewHelper);
-               $formViewHelper->expects($this->any())->method('getName')->will($this->returnValue('SomeFieldName[WithBrackets][foo]'));
-               $this->viewHelperVariableContainer->expects($this->at(0))->method('exists')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'renderedHiddenFields')->will($this->returnValue(TRUE));
-               $this->viewHelperVariableContainer->expects($this->at(1))->method('get')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'renderedHiddenFields')->will($this->returnValue(array()));
-               $this->viewHelperVariableContainer->expects($this->at(2))->method('addOrUpdate')->with(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'renderedHiddenFields', array('SomeFieldName[WithBrackets][foo]'));
+               $formViewHelper->expects($this->any())->method('getName')->will(
+                       $this->returnValue('SomeFieldName[WithBrackets][foo]')
+               );
+               $this->viewHelperVariableContainer->expects($this->at(0))->method('exists')->with(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'renderedHiddenFields'
+               )->will($this->returnValue(TRUE));
+               $this->viewHelperVariableContainer->expects($this->at(1))->method('get')->with(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'renderedHiddenFields'
+               )->will($this->returnValue([]));
+               $this->viewHelperVariableContainer->expects($this->at(2))->method('addOrUpdate')->with(
+                       \TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'renderedHiddenFields',
+                       ['SomeFieldName[WithBrackets][foo]']
+               );
                $expected = '<input type="hidden" name="SomeFieldName[WithBrackets][foo]" value="" />';
                $actual = $formViewHelper->_call('renderHiddenFieldForEmptyValue');
                $this->assertEquals($expected, $actual);
        }
 
-}
+}
\ No newline at end of file
index 6b0ad50..094ab5f 100644 (file)
@@ -27,7 +27,7 @@ class CheckboxViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\For
 
        protected function setUp() {
                parent::setUp();
-               $this->viewHelper = $this->getAccessibleMock(CheckboxViewHelper::class, array('setErrorClassAttribute', 'getName', 'getValue', 'isObjectAccessorMode', 'getPropertyValue', 'registerFieldNameForFormTokenGeneration'));
+               $this->viewHelper = $this->getAccessibleMock(CheckboxViewHelper::class, array('setErrorClassAttribute', 'getName', 'getValueAttribute', 'isObjectAccessorMode', 'getPropertyValue', 'registerFieldNameForFormTokenGeneration'));
                $this->arguments['property'] = '';
                $this->injectDependenciesIntoViewHelper($this->viewHelper);
                $this->viewHelper->initializeArguments();
@@ -45,7 +45,7 @@ class CheckboxViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\For
                $mockTagBuilder->expects($this->at(3))->method('addAttribute')->with('value', 'bar');
 
                $this->viewHelper->expects($this->any())->method('getName')->will($this->returnValue('foo'));
-               $this->viewHelper->expects($this->any())->method('getValue')->will($this->returnValue('bar'));
+               $this->viewHelper->expects($this->any())->method('getValueAttribute')->will($this->returnValue('bar'));
                $this->viewHelper->_set('tag', $mockTagBuilder);
 
                $this->viewHelper->initialize();
@@ -63,7 +63,7 @@ class CheckboxViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\For
                $mockTagBuilder->expects($this->at(4))->method('addAttribute')->with('checked', 'checked');
 
                $this->viewHelper->expects($this->any())->method('getName')->will($this->returnValue('foo'));
-               $this->viewHelper->expects($this->any())->method('getValue')->will($this->returnValue('bar'));
+               $this->viewHelper->expects($this->any())->method('getValueAttribute')->will($this->returnValue('bar'));
                $this->viewHelper->_set('tag', $mockTagBuilder);
 
                $this->viewHelper->initialize();
@@ -80,7 +80,7 @@ class CheckboxViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\For
                $mockTagBuilder->expects($this->at(3))->method('addAttribute')->with('value', 'bar');
 
                $this->viewHelper->expects($this->any())->method('getName')->will($this->returnValue('foo'));
-               $this->viewHelper->expects($this->any())->method('getValue')->will($this->returnValue('bar'));
+               $this->viewHelper->expects($this->any())->method('getValueAttribute')->will($this->returnValue('bar'));
                $this->viewHelper->expects($this->any())->method('isObjectAccessorMode')->will($this->returnValue(TRUE));
                $this->viewHelper->expects($this->any())->method('getPropertyValue')->will($this->returnValue(TRUE));
                $this->viewHelper->_set('tag', $mockTagBuilder);
@@ -101,7 +101,7 @@ class CheckboxViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\For
                $mockTagBuilder->expects($this->at(4))->method('addAttribute')->with('checked', 'checked');
 
                $this->viewHelper->expects($this->any())->method('getName')->will($this->returnValue('foo'));
-               $this->viewHelper->expects($this->any())->method('getValue')->will($this->returnValue('bar'));
+               $this->viewHelper->expects($this->any())->method('getValueAttribute')->will($this->returnValue('bar'));
                $this->viewHelper->expects($this->any())->method('isObjectAccessorMode')->will($this->returnValue(TRUE));
                $this->viewHelper->expects($this->any())->method('getPropertyValue')->will($this->returnValue(TRUE));
                $this->viewHelper->_set('tag', $mockTagBuilder);
@@ -121,7 +121,7 @@ class CheckboxViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\For
                $mockTagBuilder->expects($this->at(3))->method('addAttribute')->with('value', 'bar');
 
                $this->viewHelper->expects($this->any())->method('getName')->will($this->returnValue('foo'));
-               $this->viewHelper->expects($this->any())->method('getValue')->will($this->returnValue('bar'));
+               $this->viewHelper->expects($this->any())->method('getValueAttribute')->will($this->returnValue('bar'));
                $this->viewHelper->expects($this->any())->method('isObjectAccessorMode')->will($this->returnValue(TRUE));
                $this->viewHelper->expects($this->any())->method('getPropertyValue')->will($this->returnValue(array()));
                $this->viewHelper->_set('tag', $mockTagBuilder);
@@ -141,7 +141,7 @@ class CheckboxViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\For
                $mockTagBuilder->expects($this->at(4))->method('addAttribute')->with('checked', 'checked');
 
                $this->viewHelper->expects($this->any())->method('getName')->will($this->returnValue('foo'));
-               $this->viewHelper->expects($this->any())->method('getValue')->will($this->returnValue('bar'));
+               $this->viewHelper->expects($this->any())->method('getValueAttribute')->will($this->returnValue('bar'));
                $this->viewHelper->expects($this->any())->method('isObjectAccessorMode')->will($this->returnValue(TRUE));
                $this->viewHelper->expects($this->any())->method('getPropertyValue')->will($this->returnValue(array('foo', 'bar', 'baz')));
                $this->viewHelper->_set('tag', $mockTagBuilder);
@@ -161,7 +161,7 @@ class CheckboxViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\For
                $mockTagBuilder->expects($this->at(4))->method('addAttribute')->with('checked', 'checked');
 
                $this->viewHelper->expects($this->any())->method('getName')->will($this->returnValue('foo'));
-               $this->viewHelper->expects($this->any())->method('getValue')->will($this->returnValue('bar'));
+               $this->viewHelper->expects($this->any())->method('getValueAttribute')->will($this->returnValue('bar'));
                $this->viewHelper->expects($this->any())->method('isObjectAccessorMode')->will($this->returnValue(TRUE));
                $this->viewHelper->expects($this->any())->method('getPropertyValue')->will($this->returnValue(new \ArrayObject(array('foo', 'bar', 'baz'))));
                $this->viewHelper->_set('tag', $mockTagBuilder);
@@ -181,7 +181,7 @@ class CheckboxViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\For
                $mockTagBuilder->expects($this->at(4))->method('addAttribute')->with('checked', 'checked');
 
                $this->viewHelper->expects($this->any())->method('getName')->will($this->returnValue('foo'));
-               $this->viewHelper->expects($this->any())->method('getValue')->will($this->returnValue('bar'));
+               $this->viewHelper->expects($this->any())->method('getValueAttribute')->will($this->returnValue('bar'));
                $this->viewHelper->expects($this->any())->method('isObjectAccessorMode')->will($this->returnValue(TRUE));
                $this->viewHelper->expects($this->any())->method('getPropertyValue')->will($this->returnValue(new \stdClass()));
                $this->viewHelper->_set('tag', $mockTagBuilder);
@@ -205,7 +205,7 @@ class CheckboxViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\For
                $object3 = new \stdClass();
 
                $this->viewHelper->expects($this->any())->method('getName')->willReturn('foo');
-               $this->viewHelper->expects($this->any())->method('getValue')->willReturn(2);
+               $this->viewHelper->expects($this->any())->method('getValueAttribute')->willReturn(2);
                $this->viewHelper->expects($this->any())->method('isObjectAccessorMode')->willReturn(TRUE);
                $this->viewHelper->expects($this->any())->method('getPropertyValue')->willReturn(array($object1, $object2, $object3));
                $this->viewHelper->_set('tag', $mockTagBuilder);
index f2c09bd..babc396 100644 (file)
@@ -11,6 +11,8 @@ namespace TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form;
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
 
+use TYPO3\CMS\Fluid\ViewHelpers\Form\HiddenViewHelper;
+
 /**
  * Test for the "Hidden" Form view helper
  */
@@ -23,7 +25,7 @@ class HiddenViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\
 
        protected function setUp() {
                parent::setUp();
-               $this->viewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\ViewHelpers\Form\HiddenViewHelper::class, array('setErrorClassAttribute', 'getName', 'getValue', 'registerFieldNameForFormTokenGeneration'));
+               $this->viewHelper = $this->getAccessibleMock(HiddenViewHelper::class, array('setErrorClassAttribute', 'getName', 'getValueAttribute', 'registerFieldNameForFormTokenGeneration'));
                $this->injectDependenciesIntoViewHelper($this->viewHelper);
                $this->viewHelper->initializeArguments();
        }
@@ -40,7 +42,7 @@ class HiddenViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\
                $mockTagBuilder->expects($this->at(3))->method('addAttribute')->with('value', 'bar');
 
                $this->viewHelper->expects($this->once())->method('getName')->will($this->returnValue('foo'));
-               $this->viewHelper->expects($this->once())->method('getValue')->will($this->returnValue('bar'));
+               $this->viewHelper->expects($this->once())->method('getValueAttribute')->will($this->returnValue('bar'));
                $this->viewHelper->_set('tag', $mockTagBuilder);
 
                $this->viewHelper->initialize();
index 0af6a26..88ef8eb 100644 (file)
@@ -11,6 +11,8 @@ namespace TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form;
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
 
+use TYPO3\CMS\Fluid\ViewHelpers\Form\RadioViewHelper;
+
 /**
  * Test for the "Radio" Form view helper
  */
@@ -23,7 +25,7 @@ class RadioViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\F
 
        protected function setUp() {
                parent::setUp();
-               $this->viewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\ViewHelpers\Form\RadioViewHelper::class, array('setErrorClassAttribute', 'getName', 'getValue', 'isObjectAccessorMode', 'getPropertyValue', 'registerFieldNameForFormTokenGeneration'));
+               $this->viewHelper = $this->getAccessibleMock(RadioViewHelper::class, array('setErrorClassAttribute', 'getName', 'getValueAttribute', 'isObjectAccessorMode', 'getPropertyValue', 'registerFieldNameForFormTokenGeneration'));
                $this->injectDependenciesIntoViewHelper($this->viewHelper);
                $this->viewHelper->initializeArguments();
        }
@@ -40,7 +42,7 @@ class RadioViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\F
                $mockTagBuilder->expects($this->at(3))->method('addAttribute')->with('value', 'bar');
 
                $this->viewHelper->expects($this->any())->method('getName')->will($this->returnValue('foo'));
-               $this->viewHelper->expects($this->any())->method('getValue')->will($this->returnValue('bar'));
+               $this->viewHelper->expects($this->any())->method('getValueAttribute')->will($this->returnValue('bar'));
                $this->viewHelper->_set('tag', $mockTagBuilder);
 
                $this->viewHelper->initialize();
@@ -59,7 +61,7 @@ class RadioViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\F
                $mockTagBuilder->expects($this->at(4))->method('addAttribute')->with('checked', 'checked');
 
                $this->viewHelper->expects($this->any())->method('getName')->will($this->returnValue('foo'));
-               $this->viewHelper->expects($this->any())->method('getValue')->will($this->returnValue('bar'));
+               $this->viewHelper->expects($this->any())->method('getValueAttribute')->will($this->returnValue('bar'));
                $this->viewHelper->_set('tag', $mockTagBuilder);
 
                $this->viewHelper->initialize();
@@ -76,7 +78,7 @@ class RadioViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\F
                $mockTagBuilder->expects($this->at(3))->method('addAttribute')->with('value', 'bar');
 
                $this->viewHelper->expects($this->any())->method('getName')->will($this->returnValue('foo'));
-               $this->viewHelper->expects($this->any())->method('getValue')->will($this->returnValue('bar'));
+               $this->viewHelper->expects($this->any())->method('getValueAttribute')->will($this->returnValue('bar'));
                $this->viewHelper->expects($this->never())->method('isObjectAccessorMode')->will($this->returnValue(TRUE));
                $this->viewHelper->expects($this->never())->method('getPropertyValue')->will($this->returnValue(TRUE));
                $this->viewHelper->_set('tag', $mockTagBuilder);
@@ -98,7 +100,7 @@ class RadioViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\F
                $mockTagBuilder->expects($this->at(4))->method('addAttribute')->with('checked', 'checked');
 
                $this->viewHelper->expects($this->any())->method('getName')->will($this->returnValue('foo'));
-               $this->viewHelper->expects($this->any())->method('getValue')->will($this->returnValue('bar'));
+               $this->viewHelper->expects($this->any())->method('getValueAttribute')->will($this->returnValue('bar'));
                $this->viewHelper->expects($this->any())->method('isObjectAccessorMode')->will($this->returnValue(TRUE));
                $this->viewHelper->expects($this->any())->method('getPropertyValue')->will($this->returnValue(TRUE));
                $this->viewHelper->_set('tag', $mockTagBuilder);
@@ -118,7 +120,7 @@ class RadioViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\F
                $mockTagBuilder->expects($this->at(3))->method('addAttribute')->with('value', 'bar');
 
                $this->viewHelper->expects($this->any())->method('getName')->will($this->returnValue('foo'));
-               $this->viewHelper->expects($this->any())->method('getValue')->will($this->returnValue('bar'));
+               $this->viewHelper->expects($this->any())->method('getValueAttribute')->will($this->returnValue('bar'));
                $this->viewHelper->expects($this->any())->method('isObjectAccessorMode')->will($this->returnValue(TRUE));
                $this->viewHelper->expects($this->any())->method('getPropertyValue')->will($this->returnValue(array()));
                $this->viewHelper->_set('tag', $mockTagBuilder);
@@ -139,7 +141,7 @@ class RadioViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\F
                $mockTagBuilder->expects($this->at(4))->method('addAttribute')->with('checked', 'checked');
 
                $this->viewHelper->expects($this->any())->method('getName')->will($this->returnValue('foo'));
-               $this->viewHelper->expects($this->any())->method('getValue')->will($this->returnValue('bar'));
+               $this->viewHelper->expects($this->any())->method('getValueAttribute')->will($this->returnValue('bar'));
                $this->viewHelper->expects($this->any())->method('isObjectAccessorMode')->will($this->returnValue(TRUE));
                $this->viewHelper->expects($this->any())->method('getPropertyValue')->will($this->returnValue('bar'));
                $this->viewHelper->_set('tag', $mockTagBuilder);
index 8624044..51c40e1 100644 (file)
@@ -318,11 +318,11 @@ class SelectViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\
         */
        public function selectOnDomainObjectsCreatesExpectedOptions() {
                $mockPersistenceManager = $this->getMock(\TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface::class);
-               $mockPersistenceManager->expects($this->any())->method('getIdentifierByObject')->will($this->returnValue(NULL));
+               $mockPersistenceManager->expects($this->any())->method('getIdentifierByObject')->will($this->returnValue(2));
                $this->viewHelper->_set('persistenceManager', $mockPersistenceManager);
 
-               $this->tagBuilder->expects($this->once())->method('addAttribute')->with('name', 'myName');
-               $this->viewHelper->expects($this->once())->method('registerFieldNameForFormTokenGeneration')->with('myName');
+               $this->tagBuilder->expects($this->once())->method('addAttribute')->with('name', 'myName[__identity]');
+               $this->viewHelper->expects($this->once())->method('registerFieldNameForFormTokenGeneration')->with('myName[__identity]');
                $this->tagBuilder->expects($this->once())->method('setContent')->with('<option value="1">Ingmar</option>' . chr(10) . '<option value="2" selected="selected">Sebastian</option>' . chr(10) . '<option value="3">Robert</option>' . chr(10));
                $this->tagBuilder->expects($this->once())->method('render');
 
index 2085b38..063a8b1 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+
 namespace TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers;
 
 /*                                                                        *
@@ -21,10 +22,12 @@ namespace TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers;
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
 
+use TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\ViewHelperBaseTestcase;
+
 /**
  * Test for the Form view helper
  */
-class FormViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\ViewHelperBaseTestcase {
+class FormViewHelperTest extends ViewHelperBaseTestcase {
 
        /**
         * @var \TYPO3\CMS\Extbase\Service\ExtensionService