You are here

public function OptionsButtons::getWidgetValue in Conditional Fields 4.x

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

Get values from widget settings for plugin.

Parameters

array $value_form: Dependency options.

Return value

mixed Values for triggering events.

Overrides ConditionalFieldsHandlerBase::getWidgetValue

1 call to OptionsButtons::getWidgetValue()
OptionsButtons::checkBoxesHandler in src/Plugin/conditional_fields/handler/OptionsButtons.php
Return state for check boxes.

File

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

Class

OptionsButtons
Provides states handler for Check boxes/radio buttons.

Namespace

Drupal\conditional_fields\Plugin\conditional_fields\handler

Code

public function getWidgetValue(array $value_form) {
  $values = [];
  if (empty($value_form)) {
    return $values;
  }
  else {
    foreach ($value_form as $value) {
      if (isset($value['value'])) {
        $values[] = $value['value'];
      }
      elseif (isset($value['target_id'])) {
        $values[] = $value['target_id'];
      }
      elseif (isset($value['nid'])) {
        $values[] = $value['nid'];
      }
      elseif (isset($value['vid'])) {
        $values[] = $value['vid'];
      }
      elseif (isset($value['uid'])) {
        $values[] = $value['uid'];
      }
      elseif (isset($value['fid'])) {
        $values[] = $value['fid'];
      }
      elseif (isset($value['id'])) {
        $values[] = $value['id'];
      }
      else {
        $values[] = $value;
      }
    }
    return $values;
  }
}