public function addOptions($options = [], $selectedValue = '')
    {
        // Create all options
        foreach ($options as $value => $title) {
            // Create option
            $fi = $this->getHTMLFormFactory()->buildFormElement('option', '', $value, '', '', $title);

            // Check if it's the selected value
            if ($value == $selectedValue) {
                $fi->attr('selected', 'selected');
            }

            // Append option to select
            $this->append($fi);
        }

        // Return FormSelect object
        return $this;
    }
public function addOptions($options = [], $selectedValue = '')
    {
        // Create all options
        foreach ($options as $value => $title) {
            // Create option
            $fi = $this->getHTMLFormFactory()->buildFormElement('option', '', $value, '', '', $title);

            // Check if it's the selected value
            if ($value == $selectedValue) {
                $fi->attr('selected', 'selected');
            }

            // Append option to select
            $this->append($fi);
        }

        // Return FormSelect object
        return $this;
    }
public function addOptions ( $ options = [ ] , $ selectedValue = '' ) { // Create all options foreach ( $ options as $ value => $ title ) { // Create option $ fi = $ this -> getHTMLFormFactory ( ) -> buildFormElement ( 'option' , '' , $ value , '' , '' , $ title ) ; // Check if it's the selected value if ( $ value == $ selectedValue ) { $ fi -> attr ( 'selected' , 'selected' ) ; } // Append option to select $ this -> append ( $ fi ) ; } // Return FormSelect object return $ this ; }
Add a list of options in the select.

@param array  $options       An array of value -> title options for the select element.
@param string $selectedValue The selected value among the option keys.

@return FormSelect

@throws Exception
Add a list of options in the select .