class LanguageSelect in Conditional Fields 8
Same name and namespace in other branches
- 4.x src/Plugin/conditional_fields/handler/LanguageSelect.php \Drupal\conditional_fields\Plugin\conditional_fields\handler\LanguageSelect
Provides states handler for language select list.
Plugin annotation
@ConditionalFieldsHandler(
id = "states_handler_language_select",
)
Hierarchy
- class \Drupal\conditional_fields\ConditionalFieldsHandlerBase implements ConditionalFieldsHandlersPluginInterface
- class \Drupal\conditional_fields\Plugin\conditional_fields\handler\LanguageSelect
Expanded class hierarchy of LanguageSelect
File
- src/
Plugin/ conditional_fields/ handler/ LanguageSelect.php, line 15
Namespace
Drupal\conditional_fields\Plugin\conditional_fields\handlerView source
class LanguageSelect extends ConditionalFieldsHandlerBase {
/**
* {@inheritdoc}
*/
public function statesHandler($field, $field_info, $options) {
$state = [];
$select_states = [];
switch ($options['values_set']) {
case ConditionalFieldsInterface::CONDITIONAL_FIELDS_DEPENDENCY_VALUES_WIDGET:
$state[$options['state']][$options['selector']] = [
'value' => $this
->getWidgetValue($options['value_form']),
];
break;
case ConditionalFieldsInterface::CONDITIONAL_FIELDS_DEPENDENCY_VALUES_AND:
break;
case ConditionalFieldsInterface::CONDITIONAL_FIELDS_DEPENDENCY_VALUES_XOR:
$select_states[$options['state']][] = [
$options['selector'] => [
$options['condition'] => [
'xor' => $options['values'],
],
],
];
$state = $select_states;
break;
case ConditionalFieldsInterface::CONDITIONAL_FIELDS_DEPENDENCY_VALUES_REGEX:
$select_states[$options['state']][] = [
$options['selector'] => [
$options['condition'] => [
'regex' => $options['regex'],
],
],
];
$state = $select_states;
break;
case ConditionalFieldsInterface::CONDITIONAL_FIELDS_DEPENDENCY_VALUES_NOT:
$options['state'] = '!' . $options['state'];
case ConditionalFieldsInterface::CONDITIONAL_FIELDS_DEPENDENCY_VALUES_OR:
foreach ($options['values'] as $value) {
$select_states[$options['state']][] = [
$options['selector'] => [
$options['condition'] => empty($regex) ? [
$value,
] : $options['value'],
],
];
}
$state = $select_states;
break;
}
return $state;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConditionalFieldsHandlerBase:: |
public | function |
Get values form the condition options Overrides ConditionalFieldsHandlersPluginInterface:: |
|
ConditionalFieldsHandlerBase:: |
public | function |
Get values from widget settings for plugin. Overrides ConditionalFieldsHandlersPluginInterface:: |
5 |
LanguageSelect:: |
public | function |
Executes states handler according to conditional fields settings. Overrides ConditionalFieldsHandlersPluginInterface:: |