function ContextFormTrait::switchContextMode
Submit callback: switch a context to data selector or direct input mode.
File
-
src/
Context/ Form/ ContextFormTrait.php, line 179
Class
- ContextFormTrait
- Provides form logic for handling contexts when configuring an expression.
Namespace
Drupal\rules\Context\FormCode
public static function switchContextMode(array &$form, FormStateInterface $form_state) {
$element_name = $form_state->getTriggeringElement()['#name'];
$mode = $form_state->get($element_name);
$switched_mode = $mode == ContextDefinitionInterface::ASSIGNMENT_RESTRICTION_SELECTOR ? ContextDefinitionInterface::ASSIGNMENT_RESTRICTION_INPUT : ContextDefinitionInterface::ASSIGNMENT_RESTRICTION_SELECTOR;
$form_state->set($element_name, $switched_mode);
$form_state->setRebuild();
}