public function build()
    {
        foreach ($this->datasource as $index => $val) {

            $option = $this->createOption();

            // inner will always be used
            $option->setInner($val);
            $option->setValue($this->index_is_value ? $index : $val);

            // in dependence of the data type is value to be selected $val or $inner
            if (!empty($this->selected)) {
                // A list of selected?
                if (is_array($this->selected)) {
                    if (array_search(($this->index_is_value ? $index : $val), $this->selected)) {
                        $option->isSelected(1);
                    }
                } // Or a value to look for?
                else {
                    if ($this->selected == ($this->index_is_value ? $index : $val)) {
                        $option->isSelected(1);
                    }
                }
            }
        }

        return parent::build();
    }
public function build()
    {
        foreach ($this->datasource as $index => $val) {

            $option = $this->createOption();

            // inner will always be used
            $option->setInner($val);
            $option->setValue($this->index_is_value ? $index : $val);

            // in dependence of the data type is value to be selected $val or $inner
            if (!empty($this->selected)) {
                // A list of selected?
                if (is_array($this->selected)) {
                    if (array_search(($this->index_is_value ? $index : $val), $this->selected)) {
                        $option->isSelected(1);
                    }
                } // Or a value to look for?
                else {
                    if ($this->selected == ($this->index_is_value ? $index : $val)) {
                        $option->isSelected(1);
                    }
                }
            }
        }

        return parent::build();
    }
public function build ( ) { foreach ( $ this -> datasource as $ index => $ val ) { $ option = $ this -> createOption ( ) ; // inner will always be used $ option -> setInner ( $ val ) ; $ option -> setValue ( $ this -> index_is_value ? $ index : $ val ) ; // in dependence of the data type is value to be selected $val or $inner if ( ! empty ( $ this -> selected ) ) { // A list of selected? if ( is_array ( $ this -> selected ) ) { if ( array_search ( ( $ this -> index_is_value ? $ index : $ val ) , $ this -> selected ) ) { $ option -> isSelected ( 1 ) ; } } // Or a value to look for? else { if ( $ this -> selected == ( $ this -> index_is_value ? $ index : $ val ) ) { $ option -> isSelected ( 1 ) ; } } } } return parent :: build ( ) ; }
Builds and returns html code

@see \Core\Html\Form\Select::build()
Builds and returns html code