protected function Select::widgetCase in Conditional Fields 8
Same name and namespace in other branches
- 4.x src/Plugin/conditional_fields/handler/Select.php \Drupal\conditional_fields\Plugin\conditional_fields\handler\Select::widgetCase()
Returns state in widget input case.
1 call to Select::widgetCase()
- Select::statesHandler in src/
Plugin/ conditional_fields/ handler/ Select.php - Executes states handler according to conditional fields settings.
File
- src/
Plugin/ conditional_fields/ handler/ Select.php, line 74
Class
- Select
- Provides states handler for multiple select lists.
Namespace
Drupal\conditional_fields\Plugin\conditional_fields\handlerCode
protected function widgetCase($field, $options) {
$state = [];
$key_column = $field['#key_column'];
if (empty($key_column)) {
return $state;
}
if (!empty($options['value_form'][0][$key_column]) && $options['field_cardinality'] == 1) {
$state[$options['state']][$options['selector']] = [
'value' => $options['value_form'][0][$key_column],
];
}
else {
$values = array_column($options['value_form'], $key_column);
$state[$options['state']][$options['selector']] = [
'value' => $values,
];
}
return $state;
}