Bug #65073

SelectViewHelper doesn't handle optionValueField and optionLabelField for array options

Added by Alexander Schnitzler 6 months ago. Updated 23 days ago.

Status:Needs Feedback Start date:2015-02-14
Priority:Should have Due date:
Assigned To:Alexander Schnitzler % Done:

100%

Category:Fluid Spent time: -
Target version:7.4 (Backend)
TYPO3 Version:7 Is Regression:No
PHP Version: Sprint Focus:
Complexity:easy

Description

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

should work with the given array:
array(
    array(
        'uid' => 1,
        'title' => 'Foo'
    ),
    array(
        'uid' => -1,
        'title' => 'Bar'
    ),
    array(
        'title' => 'Baz'
    ),
    array(
        'uid' => '2'
    ),
)

Currently fluid tries to use the keys as values and the arrays as label which results in an error.


Related issues

related to TYPO3.Fluid - Bug #65424: SelectViewHelper must respect option(Value|Label)Field f... Under Review 2015-02-28
related to powermail - Bug #65792: No identifying value for object of class "" found. Resolved 2015-03-17
precedes Sphinx Python Documentation Generator - Bug #65487: PHP Warning when loading documentation in EM Closed 2015-03-03

Associated revisions

Revision 968ed7f4
Added by Alexander Schnitzler 5 months ago

[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 <>
Tested-by: Stefan Froemken <>
Tested-by: Andy Grunwald <>
Reviewed-by: Wouter Wolters <>
Reviewed-by: Anja Leichsenring <>
Tested-by: Anja Leichsenring <>

Revision 6bc5d5b4
Added by Alexander Schnitzler 5 months ago

[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/37376
Reviewed-by: Anja Leichsenring <>
Tested-by: Anja Leichsenring <>

History

#1 Updated by Gerrit Code Review 6 months ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/36909

#2 Updated by Gerrit Code Review 5 months ago

Patch set 1 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/37376

#3 Updated by Anonymous 5 months ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

#4 Updated by Stefan Neufeind 5 months ago

Also created an issue upstream at Flow-Fluid, #65424.

#5 Updated by Gerrit Code Review 5 months ago

  • Status changed from Resolved to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/37504

#6 Updated by Marcus Schwemer 5 months ago

Hi,

this breaks the current behavious as stated in post-verifies on Gerrit https://review.typo3.org/#/c/36909/

Another report is for powermail: #65792

IMO this change should be done in a non-breaking way or should be reverted.

Kind regards,
Marcus

#7 Updated by Benjamin Mack about 1 month ago

  • Target version changed from 7.1 (Cleanup) to 7.4 (Backend)

#8 Updated by Wouter Wolters 23 days ago

  • Status changed from Under Review to Needs Feedback

Still something needed here? The patch is abandoned.

Also available in: Atom PDF