public static function CshsElement::processElement in Client-side Hierarchical Select 8.3
Same name and namespace in other branches
- 8 src/Element/CshsElement.php \Drupal\cshs\Element\CshsElement::processElement()
- 8.2 src/Element/CshsElement.php \Drupal\cshs\Element\CshsElement::processElement()
File
- src/
Element/ CshsElement.php, line 61
Class
- CshsElement
- Defines the CSHS element.
Namespace
Drupal\cshs\ElementCode
public static function processElement(array $element) : array {
\assert(Inspector::assertAllStringable($element['#labels']));
// Make sure the `#none_value` doesn't overlap with other keys.
\assert(!\array_key_exists($element['#none_value'], $element['#options']));
// Make sure the `_none` option is added very at the beginning of a list.
$element['#options'] = [
$element['#none_value'] => new CshsOption($element['#none_label']),
] + $element['#options'];
$element['#attached']['library'][] = 'cshs/cshs.base';
$element['#attached']['drupalSettings'][static::ID][$element['#id']] = [
'labels' => $element['#labels'],
'noneLabel' => $element['#none_label'],
'noneValue' => (string) $element['#none_value'],
'noFirstLevelNone' => $element['#no_first_level_none'],
];
static::setAttributes($element, [
'simpler-select-root',
'form-element',
'form-element--type-select',
]);
return $element;
}