Bug #49038

form.select does not select the first item if prependOptionValue is used

Added by Axel Brand about 2 years ago.

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:

  1. select first item
  2. save object => everything is fine
  3. edit object
  4. 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.

Also available in: Atom PDF