You are here

protected static function Buttons::addStatesHandling 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::addStatesHandling()

Adds a #states array to the other field to make hide/show work.

Parameters

array $element: The select or other element.

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

File

src/Element/Buttons.php, line 66

Class

Buttons
Provides a form element with buttons and other option.

Namespace

Drupal\select_or_other\Element

Code

protected static function addStatesHandling(array &$element) {
  if (!$element['#multiple']) {
    $element['other']['#states'] = static::prepareState('visible', $element['#name'] . '[select]', 'value', 'select_or_other');
  }
  else {
    $element['other']['#states'] = static::prepareState('visible', $element['#name'] . '[select][select_or_other]', 'checked', TRUE);
  }
}