How to identify ajax request in the exposed form of the View?

Viewed 18

I have a View, it is ajax View. There are exposed filters (with checkboxes). When I select a checkbox \Drupal::routeMatch()->getRouteName() shows general route name: views.ajax

I need to change view mode in the view:

function entity_product_admin_entity_view_mode_alter(&$view_mode, \Drupal\Core\Entity\EntityInterface $entity) {
  if ($entity->getEntityTypeId() == 'node' && $entity->bundle() == 'product' && \Drupal::routeMatch()->getRouteName() == 'views.ajax') {
    $view_mode = 'product_card_full_width';
  }
}

But in case Drupal::routeMatch()->getRouteName() == 'views.ajax' $view_mode will change on all ajax requests, but I need it to change only on a specific field of the form.

0 Answers
Related