Problem/Motivation
A page with multiple Views exposed forms with AJAX enabled will trigger all form instances on the page because the form ID is the same when one of the forms is added to the page via AJAX. Also, this Drupal 7 issue is the same issue, but I didn't have a need for the cache fix there: #1735096: Allow multiple instances of the same exposed filter form on a single page
Proposed resolution
Use the Views DOM ID to have unique form IDs.
| Comment | File | Size | Author |
|---|---|---|---|
| #44 | 2968207-44.patch | 1.43 KB | gobind singh |
| #40 | 2968207-40.patch | 2.37 KB | szloredan |
| #39 | interdiff_38-39.txt | 1.2 KB | sahil.goyal |
| #39 | 2968207-39.patch | 1.43 KB | sahil.goyal |
| #38 | 2968207-38.patch | 2.25 KB | abh.ai |
Issue fork drupal-2968207
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
Comment #2
daniel korteComment #4
dawehnerI'm curious whether we could add the dom ID as data attribute? This way existing HTML ID doesn't change, and as result the risk of breaking things is reduced. Does this make sense?
Comment #5
daniel korteGood call. I ran into that exact issue. Here’s another try at it:
Comment #6
daniel korteI guess this should probably not destroy other attributes...
Comment #8
dawehner@Daniel Korte
Thank you for implementing my suggestion.
In order to ensure we don't cause a regression again I am wondering whether we could add some tests for this issue.
Comment #10
borisson_NW based on #9.
Comment #12
yury n commentedPatch from #6 does not apply against 8.6.x anymore. Updated it to work with 8.6.x
Comment #13
nortmas commentedGreat guys, thank you! Patch #12 works form me!
Comment #14
a.dmitriiev commentedRe-rolled the patch for 8.7.6, strange, but it seems to be the same as for 8.6.x, but somehow #12 doesn't apply to 8.7.5.
UPDATE: Sorry, my bad, the patch applied to 8.7.5.
Comment #15
a.dmitriiev commentedComment #17
sathish.redcrackle commentedThe above patches are not working on Ajax enabled views. It reloads the page on button click.
Also attached the screenshot showing JS errors on view forms.
Comment #19
shiraz dindar#14 is working for me. Also, I looked for AJAX errors but didn't see any.
Comment #20
pavnish commentedNeed to check for 9.0 and 9.1
Comment #21
pavnish commentedComment #22
mrinalini9 commentedRerolled patch for 9.1.x, please review.
Comment #23
weekbeforenextThe patch from #12 worked for 8.9.5. Thanks all!
Comment #25
liam morlandThere is another solution to this in #3163299: Ajax exposed filters not working for multiple instances of the same Views block placed on one page, including tests. I don't know which is the better solution.
Comment #27
liam morlandThe above is the patch from #22 as a merge request against 9.2.x.
Comment #28
alejandro cabarcos commentedPatch #22 working! Thank you.
Comment #31
leisurman commentedUsing Drupal 9.2.9. After applying the patch #22. I still get the console error - Found 2 elements with non-unique id. I am printing out a solr search exposed view form. I am printing the view twice in the twig. 1 for desktop display and another that displays only for mobile display.
Comment #32
bobooon commentedRe-rolled for 9.3.x
Comment #33
ranjith_kumar_k_u commentedComment #37
eduardo morales albertiWe tried patch #32 and seems to work disabling the caches, but when we enabled the drupal caches, the form has the ids duplicated.
So seems to be also related to cache.
Comment #38
abh.ai commentedRerolled patch for 9.5.x
Comment #39
sahil.goyal commented#38 does not get applied to 10.1x so i made it compatible so now it can applies cleany. creating interdiff giving some error so i couldn’t able to update it here!
Comment #40
szloredan commentedReroll for 9.5.x
Comment #42
rcodinaThe MR seems outdated. Patches #39 and #40 looks fine.
Comment #43
smustgrave commentedPreviously tagged for tests that are still needed.
Also issue summary could use some love.
Comment #44
gobind singh commentedRe-rolled 10.1.x / 11.x
Comment #45
rcodinaPatch on #39 was already meant for 10.1.x and 11.x and it applies and passes the tests. However, as said in #43, we still need new tests.
Comment #51
d.steindl commentedHi all!
I'm sorry, I've messed around with 11.x branch. I don't understand why, but I was not able to rebase it to 11.3.x.
After messing around I've reset the branch to the initial commit from october and force pushed the initial version back to 11.x.
.. sorry for the confusion.
After messing around with 11.x I've created a new branch (drupal-2968207-11.x) and MR for the 11.3.x version. I hope that's fine?