You are here

public static function FilterBlock::updateTagsOptions in Open Social 10.0.x

Same name and namespace in other branches
  1. 10.3.x modules/social_features/social_activity/modules/social_activity_filter/src/Plugin/views/display/FilterBlock.php \Drupal\social_activity_filter\Plugin\views\display\FilterBlock::updateTagsOptions()
  2. 10.1.x modules/social_features/social_activity/modules/social_activity_filter/src/Plugin/views/display/FilterBlock.php \Drupal\social_activity_filter\Plugin\views\display\FilterBlock::updateTagsOptions()
  3. 10.2.x modules/social_features/social_activity/modules/social_activity_filter/src/Plugin/views/display/FilterBlock.php \Drupal\social_activity_filter\Plugin\views\display\FilterBlock::updateTagsOptions()

Handles switching the available terms based on the selected vocabulary.

File

modules/social_features/social_activity/modules/social_activity_filter/src/Plugin/views/display/FilterBlock.php, line 217

Class

FilterBlock
The plugin that handles a block.

Namespace

Drupal\social_activity_filter\Plugin\views\display

Code

public static function updateTagsOptions($form, FormStateInterface $form_state) {

  // Check if there is triggered parent of element.
  if ($triggered = $form_state
    ->getTriggeringElement()) {
    $delta = is_int($triggered['#parents'][1]) ? $triggered['#parents'][1] : '';

    // Build array of parents for triggered child element.
    $parents = $triggered['#array_parents'];
    array_pop($parents);
    array_push($parents, 'tags');

    // Get triggered child element.
    $element = NestedArray::getValue($form, $parents);

    // Return child element.
    $response = new AjaxResponse();
    $response
      ->addCommand(new ReplaceCommand('#edit-block-term-wrapper-' . $delta, $element));
    return $response;
  }
}