Closed (fixed)
Project:
Views Embed Form
Version:
6.x-1.3
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
31 Dec 2010 at 20:07 UTC
Updated:
15 Jul 2011 at 02:32 UTC
Create a view that uses Global:Random as the sort criteria.
Add the Views Embed Form Test form as a field.
Notice that when we click on the submit button in the view we get a random nid in the message instead of the nid of the node from the row that we clicked the button on.
Comments
Comment #1
vkareh commentedI get this without the Global:Random - here's my scenario:
My View is using the Views Hacks module for auto-submitting exposed filters. The form embedded with Views Embed Form is a button per row, submitted using AHAH to avoid reloading the page every time a button is clicked. The View has AJAX enabled overall.
Whenever I change my exposed filters, and I click a button in position X, it will actually submit the form that was in position X *before* I changed my exposed filters. So, if I submit the first node in the filtered view, then remove the exposed filter and submit again the first node in the UN-filtered view, it will actually submit the node that was the first in the filtered view, which happens to be further down in the un-filtered view.
I wonder if this is a form caching issue - I tried forcing the form_build_id, the token, and the form_id to different, static values (form_id . $node->nid, rather than form_id . $self::counter()) and it still does the same.
Comment #2
vkareh commentedAfter much debugging, I realized that the trick is to explicitly set $form['your-submit-button']['#id'] to be strictly unique for every instance of the form, since AHAH statically caches the information set for each form, but when the form is refreshed through AJAX (by sorting or filtering), the information remains associated with the original row number, rather than the current base item.
A good example of a unique #id could be
'my-module-form-' . $row->nid