Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I needed to be able to change the form id because I need to have multiple views forms on the same page, possibly coming from the same view and display, and wanted to keep them unique. The cleanest way to achieve this that I could think of(I might be wrong though) was to make views_form_id "hookable". This way it's easy to control how the form id is build up without messing with the views module itself.
Since maybe others might find this useful/handy as well I decided to make it a feature request.
Comment | File | Size | Author |
---|---|---|---|
#1 | added_hook-1463826-2.patch | 417 bytes | FredericoT |
Comments
Comment #1
FredericoT CreditAttribution: FredericoT commentedA patch to create the hook.
Comment #2
dawehnerUpdate status
Comment #3
tim.plunkettCurrently if you have multiple views forms per page, the ids aren't unique? If so, that sounds like a bug.
If that's not true, then I don't understand the request :)
Either way, the hook would need to be documented in views.api.php, and there should be spaces after commas.
Comment #4
FredericoT CreditAttribution: FredericoT commentedCurrently the form id is build up using the string 'views_form' and then adding the view machine name and the machine name of the current display. However in my specific case the view name and display name are the same for certain forms on the same page. Because of this the form id is not unique in this case and this causes some issues for me. I don't think this really qualifies as a bug since it's a rather specific case and I don't see many people having any issue with this. A simple fix would be to add a unique number or something like that to the end of the form id, however I would personally prefer to be able to control it myself. I don't have a lot of time at the moment but I'll update my patch as soon as I get a chance.
Comment #5
HnLn CreditAttribution: HnLn commentedPatch works for me.
I wanted to use views_field_view to embed multiple draggable views in one parent view. Without the patch the forms don't submit correctly, with the patch it works.
Comment #6
VSZ CreditAttribution: VSZ commentedThis patched worked for me.
Is there any chance it will be included into release?