You are here

public function OptionsButtons::statesHandler in Conditional Fields 8

Same name and namespace in other branches
  1. 4.x src/Plugin/conditional_fields/handler/OptionsButtons.php \Drupal\conditional_fields\Plugin\conditional_fields\handler\OptionsButtons::statesHandler()

Executes states handler according to conditional fields settings.

Overrides ConditionalFieldsHandlersPluginInterface::statesHandler

File

src/Plugin/conditional_fields/handler/OptionsButtons.php, line 20

Class

OptionsButtons
Provides states handler for Check boxes/radio buttons.

Namespace

Drupal\conditional_fields\Plugin\conditional_fields\handler

Code

public function statesHandler($field, $field_info, $options) {
  if (array_key_exists('#type', $field) && in_array($field['#type'], [
    'checkbox',
    'checkboxes',
  ])) {

    // Check boxes.
    return $this
      ->checkBoxesHandler($field, $field_info, $options);
  }
  elseif (array_key_exists('#type', $field) && in_array($field['#type'], [
    'radio',
    'radios',
  ])) {

    // Radio.
    return $this
      ->radioHandler($field, $field_info, $options);
  }
  return [];
}