public function selectField(SelectField $selectField)
    {
        $value = $selectField->getValue();
        $values = is_array($value) ? $value : array((string)$value);

        $innerHtml = '';

        // walk all options
        foreach ($selectField->getOptions() as $option) {
            // set selected if the value matches
            if ($option instanceof Option) {
                $option->setSelected(in_array((string)$option->getValue(), $values));
            } else {
                if ($option instanceof Optgroup) {
                    foreach ($option->getOptions() as $option2) {
                        $option2->setSelected(in_array((string)$option2->getValue(), $values));
                    }
                }
            }

            $innerHtml .= $this->render($option);
        }

        $tag = new Tag('select', $innerHtml);

        if ($selectField->isMultiple()) {
            $tag->setAttribute('multiple', 'multiple');
        }

        return $this->parseTag($tag, $selectField);
    }
public function selectField(SelectField $selectField)
    {
        $value = $selectField->getValue();
        $values = is_array($value) ? $value : array((string)$value);

        $innerHtml = '';

        // walk all options
        foreach ($selectField->getOptions() as $option) {
            // set selected if the value matches
            if ($option instanceof Option) {
                $option->setSelected(in_array((string)$option->getValue(), $values));
            } else {
                if ($option instanceof Optgroup) {
                    foreach ($option->getOptions() as $option2) {
                        $option2->setSelected(in_array((string)$option2->getValue(), $values));
                    }
                }
            }

            $innerHtml .= $this->render($option);
        }

        $tag = new Tag('select', $innerHtml);

        if ($selectField->isMultiple()) {
            $tag->setAttribute('multiple', 'multiple');
        }

        return $this->parseTag($tag, $selectField);
    }
public function selectField ( SelectField $ selectField ) { $ value = $ selectField -> getValue ( ) ; $ values = is_array ( $ value ) ? $ value : array ( ( string ) $ value ) ; $ innerHtml = '' ; // walk all options foreach ( $ selectField -> getOptions ( ) as $ option ) { // set selected if the value matches if ( $ option instanceof Option ) { $ option -> setSelected ( in_array ( ( string ) $ option -> getValue ( ) , $ values ) ) ; } else { if ( $ option instanceof Optgroup ) { foreach ( $ option -> getOptions ( ) as $ option2 ) { $ option2 -> setSelected ( in_array ( ( string ) $ option2 -> getValue ( ) , $ values ) ) ; } } } $ innerHtml .= $ this -> render ( $ option ) ; } $ tag = new Tag ( 'select' , $ innerHtml ) ; if ( $ selectField -> isMultiple ( ) ) { $ tag -> setAttribute ( 'multiple' , 'multiple' ) ; } return $ this -> parseTag ( $ tag , $ selectField ) ; }
Render a selectField

@param SelectField $selectField
@return string
Render a selectField