protected static function Select::addEmptyOption in Select (or other) 4.x
Same name and namespace in other branches
- 8 src/Element/Select.php \Drupal\select_or_other\Element\Select::addEmptyOption()
Adds an empty option to the select element if required.
Parameters
array $element: The select or other element.
1 call to Select::addEmptyOption()
- Select::processSelectOrOther in src/
Element/ Select.php - Render API callback: Expands the select_or_other element type.
File
- src/
Element/ Select.php, line 46
Class
- Select
- Provides a form element with a select box and other option.
Namespace
Drupal\select_or_other\ElementCode
protected static function addEmptyOption(array &$element) {
if (!isset($element['#no_empty_option']) || !$element['#no_empty_option']) {
if (!$element['#required'] || empty($element['#default_value'])) {
$element['select']['#empty_value'] = '';
}
}
}