Revert "[BUGFIX] SelectViewHelper must respect option(Value|Label)Field for arrays" 59/37959/2
authorAnja Leichsenring <aleichsenring@ab-softlab.de>
Thu, 19 Mar 2015 18:12:10 +0000 (19:12 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Thu, 19 Mar 2015 18:12:29 +0000 (19:12 +0100)
This reverts commit 6bc5d5b4bc5359f7ff47f43de3398b7836531c25.

The commit introduces changing behaviour and therefore a regression in stable branch. See description and comments in  https://forge.typo3.org/issues/65792

Change-Id: I949916f54dd81ca03ffe66b46b34fb63fa54b8d7
Resolves: #65792
Releases: 6.2
Reviewed-on: http://review.typo3.org/37959
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/fluid/Classes/ViewHelpers/Form/SelectViewHelper.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/SelectViewHelperTest.php

index 3d719e1..987d148 100644 (file)
@@ -155,7 +155,7 @@ class SelectViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFie
                $options = array();
                $optionsArgument = $this->arguments['options'];
                foreach ($optionsArgument as $key => $value) {
-                       if (is_object($value) || is_array($value)) {
+                       if (is_object($value)) {
                                if ($this->hasArgument('optionValueField')) {
                                        $key = \TYPO3\CMS\Extbase\Reflection\ObjectAccess::getPropertyPath($value, $this->arguments['optionValueField']);
                                        if (is_object($key)) {
index 9bf65cf..75a2582 100644 (file)
@@ -84,113 +84,6 @@ class SelectViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\
        /**
         * @test
         */
-       public function selectCreatesExpectedOptionsWithArraysAndOptionValueFieldAndOptionLabelFieldSet() {
-               $this->tagBuilder->expects($this->once())->method('setContent')->with(
-                       '<option value="2"></option>' . chr(10) .
-                       '<option value="-1">Bar</option>' . chr(10) .
-                       '<option value="">Baz</option>' . chr(10) .
-                       '<option value="1">Foo</option>' . chr(10)
-               );
-
-               $this->arguments['optionValueField'] = 'uid';
-               $this->arguments['optionLabelField'] = 'title';
-               $this->arguments['sortByOptionLabel'] = TRUE;
-               $this->arguments['options'] = array(
-                       array(
-                               'uid' => 1,
-                               'title' => 'Foo'
-                       ),
-                       array(
-                               'uid' => -1,
-                               'title' => 'Bar'
-                       ),
-                       array(
-                               'title' => 'Baz'
-                       ),
-                       array(
-                               'uid' => '2'
-                       ),
-               );
-
-               $this->injectDependenciesIntoViewHelper($this->viewHelper);
-               $this->viewHelper->initialize();
-               $this->viewHelper->render();
-       }
-
-       /**
-        * @test
-        */
-       public function selectCreatesExpectedOptionsWithStdClassesAndOptionValueFieldAndOptionLabelFieldSet() {
-               $this->tagBuilder->expects($this->once())->method('setContent')->with(
-                       '<option value="2"></option>' . chr(10) .
-                       '<option value="-1">Bar</option>' . chr(10) .
-                       '<option value="">Baz</option>' . chr(10) .
-                       '<option value="1">Foo</option>' . chr(10)
-               );
-
-               $obj1 = new \StdClass();
-               $obj1->uid = 1;
-               $obj1->title = 'Foo';
-
-               $obj2 = new \StdClass();
-               $obj2->uid = -1;
-               $obj2->title = 'Bar';
-
-               $obj3 = new \StdClass();
-               $obj3->title = 'Baz';
-
-               $obj4 = new \StdClass();
-               $obj4->uid = 2;
-
-               $this->arguments['optionValueField'] = 'uid';
-               $this->arguments['optionLabelField'] = 'title';
-               $this->arguments['sortByOptionLabel'] = TRUE;
-               $this->arguments['options'] = array($obj1, $obj2, $obj3, $obj4);
-
-               $this->injectDependenciesIntoViewHelper($this->viewHelper);
-               $this->viewHelper->initialize();
-               $this->viewHelper->render();
-       }
-
-       /**
-        * @test
-        */
-       public function selectCreatesExpectedOptionsWithArrayObjectsAndOptionValueFieldAndOptionLabelFieldSet() {
-               $this->tagBuilder->expects($this->once())->method('setContent')->with(
-                       '<option value="2"></option>' . chr(10) .
-                       '<option value="-1">Bar</option>' . chr(10) .
-                       '<option value="">Baz</option>' . chr(10) .
-                       '<option value="1">Foo</option>' . chr(10)
-               );
-
-               $this->arguments['optionValueField'] = 'uid';
-               $this->arguments['optionLabelField'] = 'title';
-               $this->arguments['sortByOptionLabel'] = TRUE;
-               $this->arguments['options'] = new \ArrayObject(array(
-                       array(
-                               'uid' => 1,
-                               'title' => 'Foo'
-                       ),
-                       array(
-                               'uid' => -1,
-                               'title' => 'Bar'
-                       ),
-                       array(
-                               'title' => 'Baz'
-                       ),
-                       array(
-                               'uid' => '2'
-                       ),
-               ));
-
-               $this->injectDependenciesIntoViewHelper($this->viewHelper);
-               $this->viewHelper->initialize();
-               $this->viewHelper->render();
-       }
-
-       /**
-        * @test
-        */
        public function anEmptyOptionTagIsRenderedIfOptionsArrayIsEmptyToAssureXhtmlCompatibility() {
                $this->tagBuilder->expects($this->once())->method('addAttribute')->with('name', 'myName');
                $this->viewHelper->expects($this->once())->method('registerFieldNameForFormTokenGeneration')->with('myName');