src/Helpers/FormRenderer.php
protected function select(array $field)
    {
        $output = '';

        // Tag around select element: same as for an input element.
        $output .= $this->getWrapper('input');

        // Select tag.
        $attributes = $field['attributes'];
        $attributes = $this->addAttribute($attributes, 'id', $field['id']);
        $attributes = $this->addAttribute($attributes, 'name', $field['name']);
        $output .= $this->getOpenTag('select', $attributes);

        // Options.
        foreach ($field['options'] as $value => $text) {
            $optionAttributes = array('value' => $value);
            if ($this->isOptionSelected($field['value'], $value)) {
                $optionAttributes['selected'] = true;
            }
            $output .= $this->getOpenTag('option', $optionAttributes);
            $output .= htmlspecialchars($text, $this->htmlSpecialCharsFlag, 'UTF-8');
            $output .= $this->getCloseTag('option');
        }

        // End tag.
        $output .= $this->getCloseTag('select');
        // Tag around select element.
        $output .= $this->getWrapperEnd('input');

        return $output;
    }
protected function select(array $field)
    {
        $output = '';

        // Tag around select element: same as for an input element.
        $output .= $this->getWrapper('input');

        // Select tag.
        $attributes = $field['attributes'];
        $attributes = $this->addAttribute($attributes, 'id', $field['id']);
        $attributes = $this->addAttribute($attributes, 'name', $field['name']);
        $output .= $this->getOpenTag('select', $attributes);

        // Options.
        foreach ($field['options'] as $value => $text) {
            $optionAttributes = array('value' => $value);
            if ($this->isOptionSelected($field['value'], $value)) {
                $optionAttributes['selected'] = true;
            }
            $output .= $this->getOpenTag('option', $optionAttributes);
            $output .= htmlspecialchars($text, $this->htmlSpecialCharsFlag, 'UTF-8');
            $output .= $this->getCloseTag('option');
        }

        // End tag.
        $output .= $this->getCloseTag('select');
        // Tag around select element.
        $output .= $this->getWrapperEnd('input');

        return $output;
    }
protected function select ( array $ field ) { $ output = '' ; // Tag around select element: same as for an input element. $ output .= $ this -> getWrapper ( 'input' ) ; // Select tag. $ attributes = $ field [ 'attributes' ] ; $ attributes = $ this -> addAttribute ( $ attributes , 'id' , $ field [ 'id' ] ) ; $ attributes = $ this -> addAttribute ( $ attributes , 'name' , $ field [ 'name' ] ) ; $ output .= $ this -> getOpenTag ( 'select' , $ attributes ) ; // Options. foreach ( $ field [ 'options' ] as $ value => $ text ) { $ optionAttributes = array ( 'value' => $ value ) ; if ( $ this -> isOptionSelected ( $ field [ 'value' ] , $ value ) ) { $ optionAttributes [ 'selected' ] = true ; } $ output .= $ this -> getOpenTag ( 'option' , $ optionAttributes ) ; $ output .= htmlspecialchars ( $ text , $ this -> htmlSpecialCharsFlag , 'UTF-8' ) ; $ output .= $ this -> getCloseTag ( 'option' ) ; } // End tag. $ output .= $ this -> getCloseTag ( 'select' ) ; // Tag around select element. $ output .= $ this -> getWrapperEnd ( 'input' ) ; return $ output ; }
Renders a select element.

@param array $field

@return string
The rendered select element.
Renders a select element .