You are here

public function SocialGroupViewsBulkOperationsBulkForm::viewsFormValidate in Open Social 10.0.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_group/src/Plugin/views/field/SocialGroupViewsBulkOperationsBulkForm.php \Drupal\social_group\Plugin\views\field\SocialGroupViewsBulkOperationsBulkForm::viewsFormValidate()
  2. 8.5 modules/social_features/social_group/src/Plugin/views/field/SocialGroupViewsBulkOperationsBulkForm.php \Drupal\social_group\Plugin\views\field\SocialGroupViewsBulkOperationsBulkForm::viewsFormValidate()
  3. 8.6 modules/social_features/social_group/src/Plugin/views/field/SocialGroupViewsBulkOperationsBulkForm.php \Drupal\social_group\Plugin\views\field\SocialGroupViewsBulkOperationsBulkForm::viewsFormValidate()
  4. 8.7 modules/social_features/social_group/src/Plugin/views/field/SocialGroupViewsBulkOperationsBulkForm.php \Drupal\social_group\Plugin\views\field\SocialGroupViewsBulkOperationsBulkForm::viewsFormValidate()
  5. 8.8 modules/social_features/social_group/src/Plugin/views/field/SocialGroupViewsBulkOperationsBulkForm.php \Drupal\social_group\Plugin\views\field\SocialGroupViewsBulkOperationsBulkForm::viewsFormValidate()
  6. 10.3.x modules/social_features/social_group/src/Plugin/views/field/SocialGroupViewsBulkOperationsBulkForm.php \Drupal\social_group\Plugin\views\field\SocialGroupViewsBulkOperationsBulkForm::viewsFormValidate()
  7. 10.1.x modules/social_features/social_group/src/Plugin/views/field/SocialGroupViewsBulkOperationsBulkForm.php \Drupal\social_group\Plugin\views\field\SocialGroupViewsBulkOperationsBulkForm::viewsFormValidate()
  8. 10.2.x modules/social_features/social_group/src/Plugin/views/field/SocialGroupViewsBulkOperationsBulkForm.php \Drupal\social_group\Plugin\views\field\SocialGroupViewsBulkOperationsBulkForm::viewsFormValidate()

Overrides ViewsBulkOperationsBulkForm::viewsFormValidate

File

modules/social_features/social_group/src/Plugin/views/field/SocialGroupViewsBulkOperationsBulkForm.php, line 186

Class

SocialGroupViewsBulkOperationsBulkForm
Defines the Groups Views Bulk Operations field plugin.

Namespace

Drupal\social_group\Plugin\views\field

Code

public function viewsFormValidate(&$form, FormStateInterface $form_state) {
  if ($this->view
    ->id() === 'group_manage_members') {
    $user_input = $form_state
      ->getUserInput();
    $available_options = $this
      ->getBulkOptions();

    // Grab all the actions that are available.
    foreach (Element::children($this->actions) as $action) {

      // If the option is not in our selected options, next.
      if (empty($available_options[$action])) {
        continue;
      }

      /** @var \Drupal\Core\StringTranslation\TranslatableMarkup $label */
      $label = $available_options[$action];

      // Match the Users action from our custom dropdown.
      // Find the action from the VBO selection.
      // And set that as the chosen action in the form_state.
      if (strip_tags($label
        ->render()) === $user_input['op']) {
        $user_input['action'] = $action;
        $form_state
          ->setUserInput($user_input);
        $form_state
          ->setValue('action', $action);
        $form_state
          ->setTriggeringElement($this->actions[$action]);
        break;
      }
    }
  }
  parent::viewsFormValidate($form, $form_state);
}