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.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | drupal-10-1-breaks-ajax-views-3376815-2.patch | 1.09 KB | falco010 |
Issue fork viewsreference-3376815
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:
- 3376815-drupal-10.1-breaks
changes, plain diff MR !32
Comments
Comment #2
falco010Hereby the patch that solves this issue, succesfully tested on fresh Drupal 10.1.0 & 10.0.8.
Comment #6
jrglasgow commentedI 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.
Comment #7
jrglasgow commentedComment #9
seanbCommitted, thanks!