Bug #49038
form.select does not select the first item if prependOptionValue is used
Status: | New | Start date: | 2013-06-11 | |
---|---|---|---|---|
Priority: | Must have | Due date: | ||
Assigned To: | - | % Done: | 0% |
|
Category: | - | |||
Target version: | - | |||
Has patch: | No | Affected Flow version: | FLOW3 1.1.0 |
Description
I habe a strange behaviour.
I use the f:form.select viewhelper like this:
<f:form.select property="myadata" options="{mydatas}" optionLabelField="name" optionValueField="uid" sortByOptionLabel="TRUE" prependOptionLabel="" />
Here the action:
- select first item
- save object => everything is fine
- edit object
- first item is NOT selected
If i try this with the second one or if i delete the prependOptionLabel attribute, everything is running fine.
I hacked the view-helper-class SelectViewHelper.php
like this:
protected function isSelected($value) { $this->getSelectedValue(); $selectedValue = $this->getSelectedValue(); if ($value === $selectedValue || (string) $value === $selectedValue) { return TRUE; } if ($this->hasArgument('multiple')) { if (is_null($selectedValue) && $this->arguments['selectAllByDefault'] === TRUE) { return TRUE; } elseif (is_array($selectedValue) && in_array($value, $selectedValue)) { return TRUE; } } return FALSE; }
The line
$this->getSelectedValue();
is the trick.