Problem/Motivation

When using ajax views the dynamic views reference setting plugins do not apply their changes to the results. For example when you enable a pager for the view, the code in the field formatter does not run.

I tested this on a fresh Drupal 10.1 and could reproduce it there. On Drupal 10.0 I was not able to reproduce it.

Steps to reproduce

  • Install a fresh Drupal 10.1
  • Install latest 2.x Viewsreference
  • Create a view which has Ajax enabled (default no pagination)
  • Create a field with Viewsreference
  • Create a page with Viewsreference (set Full or Mini pagination)
  • After clicking on next page in pagination, all Viewsreference settings are lost

Proposed resolution

In viewsreference_views_pre_view():

Change:

$view->getRequest()->request->all('viewsreference')

to:

$view->getRequest()->query->all('viewsreference')

This seems to fix the issue.

I could not find what exact change in Drupal core 10.1 broke this, maybe anyone else knows?

If you are applying the patch to 8.x-2.0-beta4 you must first apply the patch for #3326841: Ajax pager - Input value "viewsreference" contains a non-scalar value first or this patch will not apply.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Falco010 created an issue. See original summary.

falco010’s picture

Status: Active » Needs review
StatusFileSize
new1.09 KB

Hereby the patch that solves this issue, succesfully tested on fresh Drupal 10.1.0 & 10.0.8.

Lukey made their first commit to this issue’s fork.

jrglasgow made their first commit to this issue’s fork.

jrglasgow’s picture

Status: Needs review » Reviewed & tested by the community

I have verified that this patch works to fix the problem for me.... though the patch for #3326841: Ajax pager - Input value "viewsreference" contains a non-scalar value must be applied to 8.x-2.0-beta4 first or else this patch won't apply.

jrglasgow’s picture

Issue summary: View changes

  • Falco010 authored 3d1d66cc on 8.x-2.x
    Issue #3376815 by Falco010, jrglasgow, Lukey, seanB: Drupal 10.1 breaks...
seanb’s picture

Status: Reviewed & tested by the community » Fixed

Committed, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.