src/FieldBuilder.php
protected function addEmptyOption($name, array $options, array &$attributes)
    {
        if (empty($options)) {
            return [];
        }

        // Don't add an empty option if the select is "multiple"
        if (isset($attributes['multiple']) || in_array('multiple', $attributes)) {
            return $options;
        }

        if (isset($attributes['empty'])) {
            $text = $attributes['empty'];
            unset($attributes['empty']);
        } else {
            $text = $this->getEmptyOption($name);
        }

        if ($text === false) {
            return $options;
        }

        return ['' => $text] + $options;
    }
protected function addEmptyOption($name, array $options, array &$attributes)
    {
        if (empty($options)) {
            return [];
        }

        // Don't add an empty option if the select is "multiple"
        if (isset($attributes['multiple']) || in_array('multiple', $attributes)) {
            return $options;
        }

        if (isset($attributes['empty'])) {
            $text = $attributes['empty'];
            unset($attributes['empty']);
        } else {
            $text = $this->getEmptyOption($name);
        }

        if ($text === false) {
            return $options;
        }

        return ['' => $text] + $options;
    }
protected function addEmptyOption ( $ name , array $ options , array & $ attributes ) { if ( empty ( $ options ) ) { return [ ] ; } // Don't add an empty option if the select is "multiple" if ( isset ( $ attributes [ 'multiple' ] ) || in_array ( 'multiple' , $ attributes ) ) { return $ options ; } if ( isset ( $ attributes [ 'empty' ] ) ) { $ text = $ attributes [ 'empty' ] ; unset ( $ attributes [ 'empty' ] ) ; } else { $ text = $ this -> getEmptyOption ( $ name ) ; } if ( $ text === false ) { return $ options ; } return [ '' => $ text ] + $ options ; }
Adds an empty option for select inputs if the option list is not empty.

You can pass the empty option's text as the "empty" key in the
attribute's array. Or you can set this as a lang's key (see the
getEmptyOption method below).

@param $name
@param array $options
@param array $attributes

@return array
Adds an empty option for select inputs if the option list is not empty .