[BUGFIX] SelectViewHelper must respect option(Value|Label)Field for arrays 09/36909/2
authorAlexander Schnitzler <git@alexanderschnitzler.de>
Sat, 14 Feb 2015 16:32:28 +0000 (17:32 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Sat, 28 Feb 2015 20:46:20 +0000 (21:46 +0100)
commit968ed7f4420b67e0811ef2126a8504cce44a8a6b
treebc18233a74ae179a01d77e36fb4f5886d215b83e
parent4026844869fd9b4ce53d41a64ac11d18a0d080d0
[BUGFIX] SelectViewHelper must respect option(Value|Label)Field for arrays

The SelectViewHelper tries to resolve the value and label
field as long as options are of type object, i.e. domain
objects but that functionality must also exist for arrays
because their structure is similar to objects.

Example:
<f:form.select
options="{items}"
optionValueField="uid"
optionLabelField="title"
/>

$items = array(
    0 => array(
        'uid' => 1,
        'title' => 'Foo'
    ),
);

Currently the view helper tries to use the array key as
value field (i.e. 0) and the array value (i.e. array) as
label and fails calling htmlspecialchars on the array.

This patch allows values to be arrays themselves and to
be treated like domain objects.

Resolves: #65073
Releases: master, 6.2
Change-Id: Ia803ceb38c1f7488d48863f5a6781b229def50c4
Reviewed-on: http://review.typo3.org/36909
Reviewed-by: Stefan Froemken <froemken@gmail.com>
Tested-by: Stefan Froemken <froemken@gmail.com>
Tested-by: Andy Grunwald <andygrunwald@gmail.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
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