When adding AJAX filters to a view with a toggle field, a normal checkbox is visible. And not the toggle.

I think some javascript in the attached behaviours is required for this module

Comments

Marceldeb created an issue.

marceldeb’s picture

Next to a drupal.attached behaviour I propose to add a hook_form alte. This is needed because when view filters are applied, the AJAX url is set to /views/ajax which is incorrect in our case.

if (\Drupal::routeMatch()->getRouteName() === 'views.ajax' && isset($form['checkbox'])) {
    $referer = \Drupal::request()->server->get('HTTP_REFERER');

    $form['checkbox']['#ajax']['url'] = Url::fromUri($referer);
    $form['checkbox']['#ajax']['options'] = ['query' => \Drupal::request()->query->all() + [FormBuilderInterface::AJAX_FORM_REQUEST => TRUE]];

  }

If i am added to the project i'm happy to push these fixes.