You are here

public static function Select2::elementApplyPropertyRecursive in Select2 ALL THE THINGS! 8

Recurse through an element to apply the Select2 property to any select fields.

Parameters

array $element: The element.

int $select2_value: Select2 setting.

1 call to Select2::elementApplyPropertyRecursive()
Select2::preRenderDateCombo in src/Select2.php
Render API callback: Apply Select2 to a date_combo element.

File

src/Select2.php, line 162

Class

Select2
Methods for adding Select2 to render elements.

Namespace

Drupal\select2_all

Code

public static function elementApplyPropertyRecursive(array &$element, $select2_value = NULL) {
  if (!isset($select2_value)) {
    if (isset($element['#select2'])) {
      $select2_value = $element['#select2'];
    }
    else {
      return;
    }
  }
  if (isset($element['#type']) && $element['#type'] === 'select') {
    $element['#chosen'] = $select2_value;
  }
  foreach (Element::children($element) as $key) {
    static::elementApplyPropertyRecursive($element[$key], $select2_value);
  }
}