Returns the empty option to add to the list of options, if any.
string|null Either static::OPTIONS_EMPTY_NONE, static::OPTIONS_EMPTY_SELECT, or NULL.
Overrides OptionsWidgetBase::getEmptyOption
protected function getEmptyOption() {
if ($this->multiple) {
// Multiple select: add a 'none' option for non-required fields.
if (!$this->required) {
return static::OPTIONS_EMPTY_NONE;
}
}
else {
// Single select: add a 'none' option for non-required fields,
// and a 'select a value' option for required fields that do not come
// with a value selected.
if (!$this->required) {
return static::OPTIONS_EMPTY_NONE;
}
if (!$this->has_value) {
return static::OPTIONS_EMPTY_SELECT;
}
}
}