You are here

protected static function Buttons::setSelectType in Select (or other) 8

Same name and namespace in other branches
  1. 4.x src/Element/Buttons.php \Drupal\select_or_other\Element\Buttons::setSelectType()

Sets the type of buttons to use for the select element.

Parameters

array $element: The select or other element.

1 call to Buttons::setSelectType()
Buttons::processSelectOrOther in src/Element/Buttons.php
Render API callback: Expands the select_or_other element type.

File

src/Element/Buttons.php, line 35

Class

Buttons
Provides a form element with buttons and other option.

Namespace

Drupal\select_or_other\Element

Code

protected static function setSelectType(array &$element) {
  if ($element['#multiple']) {
    $element['select']['#type'] = 'checkboxes';
  }
  else {
    $element['select']['#type'] = 'radios';
    static::ensureCorrectDefaultValue($element);
  }
}