concrete/src/Form/Service/Form.php
public function selectMultiple($key, $optionValues, $defaultValues = false, $miscFields = [])
    {
        $requestValue = $this->getRequestValue($key . '[]');
        if ($requestValue !== false) {
            $selectedValues = $requestValue;
        } else {
            $selectedValues = $defaultValues;
        }
        if (!is_array($selectedValues)) {
            if (isset($selectedValues) && ($selectedValues !== false)) {
                $selectedValues = (array) $selectedValues;
            } else {
                $selectedValues = [];
            }
        }
        if (!is_array($optionValues)) {
            $optionValues = [];
        }
        $str = "<select id=\"$key\" name=\"{$key}[]\" multiple=\"multiple\"" . $this->parseMiscFields('form-control', $miscFields) . '>';
        foreach ($optionValues as $k => $text) {
            $str .= '<option value="' . h($k) . '"';
            if (in_array($k, $selectedValues)) {
                $str .= ' selected="selected"';
            }
            $str .= '>' . $text . '</option>';
        }
        $str .= '</select>';

        return $str;
    }
public function selectMultiple($key, $optionValues, $defaultValues = false, $miscFields = [])
    {
        $requestValue = $this->getRequestValue($key . '[]');
        if ($requestValue !== false) {
            $selectedValues = $requestValue;
        } else {
            $selectedValues = $defaultValues;
        }
        if (!is_array($selectedValues)) {
            if (isset($selectedValues) && ($selectedValues !== false)) {
                $selectedValues = (array) $selectedValues;
            } else {
                $selectedValues = [];
            }
        }
        if (!is_array($optionValues)) {
            $optionValues = [];
        }
        $str = "<select id=\"$key\" name=\"{$key}[]\" multiple=\"multiple\"" . $this->parseMiscFields('form-control', $miscFields) . '>';
        foreach ($optionValues as $k => $text) {
            $str .= '<option value="' . h($k) . '"';
            if (in_array($k, $selectedValues)) {
                $str .= ' selected="selected"';
            }
            $str .= '>' . $text . '</option>';
        }
        $str .= '</select>';

        return $str;
    }
public function selectMultiple ( $ key , $ optionValues , $ defaultValues = false , $ miscFields = [ ] ) { $ requestValue = $ this -> getRequestValue ( $ key . '[]' ) ; if ( $ requestValue !== false ) { $ selectedValues = $ requestValue ; } else { $ selectedValues = $ defaultValues ; } if ( ! is_array ( $ selectedValues ) ) { if ( isset ( $ selectedValues ) && ( $ selectedValues !== false ) ) { $ selectedValues = ( array ) $ selectedValues ; } else { $ selectedValues = [ ] ; } } if ( ! is_array ( $ optionValues ) ) { $ optionValues = [ ] ; } $ str = "<select id=\"$key\" name=\"{$key}[]\" multiple=\"multiple\"" . $ this -> parseMiscFields ( 'form-control' , $ miscFields ) . '>' ; foreach ( $ optionValues as $ k => $ text ) { $ str .= '<option value="' . h ( $ k ) . '"' ; if ( in_array ( $ k , $ selectedValues ) ) { $ str .= ' selected="selected"' ; } $ str .= '>' . $ text . '</option>' ; } $ str .= '</select>' ; return $ str ; }
Renders a multiple select box.

@param string $key The ID of the element. The name attribute will be $key followed by '[].
@param array $optionValues Hash array with name/value as the select's option value/text
@param array|string $defaultValues Default value(s) which match with the option values; overridden by $_REQUEST
@param array $miscFields additional fields appended to the element (a hash array of attributes name => value), possibly including 'class'

@return $html
Renders a multiple select box .