Bug #49038
form.select does not select the first item if prependOptionValue is used
Status:
New
Priority:
Must have
Assignee:
-
Category:
-
Target version:
-
Start date:
2013-06-11
Due date:
% Done:
0%
Estimated time:
Has patch:
No
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.
No data to display