src/Framework/Form/Element/Select.php
public function setValue($value)
    {
        $this->selected = $value;
        if ($this->hasChildren()) {
            foreach ($this->childNodes as $child) {
                if ($child instanceof Select\Option) {
                    if ($child->getValue() == $this->selected) {
                        $child->select();
                    } else {
                        $child->deselect();
                    }
                } else if ($child instanceof Select\Optgroup) {
                    $options = $child->getOptions();
                    foreach ($options as $option) {
                        if ($option->getValue() == $this->selected) {
                            $option->select();
                        } else {
                            $option->deselect();
                        }
                    }
                }
            }
        }
        return $this;
    }
public function setValue($value)
    {
        $this->selected = $value;
        if ($this->hasChildren()) {
            foreach ($this->childNodes as $child) {
                if ($child instanceof Select\Option) {
                    if ($child->getValue() == $this->selected) {
                        $child->select();
                    } else {
                        $child->deselect();
                    }
                } else if ($child instanceof Select\Optgroup) {
                    $options = $child->getOptions();
                    foreach ($options as $option) {
                        if ($option->getValue() == $this->selected) {
                            $option->select();
                        } else {
                            $option->deselect();
                        }
                    }
                }
            }
        }
        return $this;
    }
public function setValue ( $ value ) { $ this -> selected = $ value ; if ( $ this -> hasChildren ( ) ) { foreach ( $ this -> childNodes as $ child ) { if ( $ child instanceof Select \ Option ) { if ( $ child -> getValue ( ) == $ this -> selected ) { $ child -> select ( ) ; } else { $ child -> deselect ( ) ; } } else if ( $ child instanceof Select \ Optgroup ) { $ options = $ child -> getOptions ( ) ; foreach ( $ options as $ option ) { if ( $ option -> getValue ( ) == $ this -> selected ) { $ option -> select ( ) ; } else { $ option -> deselect ( ) ; } } } } } return $ this ; }
Set the selected value of the select form element

@param  mixed $value
@return Select
Set the selected value of the select form element