Closed (fixed)
Project:
Drupal core
Version:
4.7.0
Component:
forms system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
8 May 2006 at 01:47 UTC
Updated:
6 Oct 2006 at 21:04 UTC
Jump to comment: Most recent file
Comments
Comment #1
Steven commentedEssentially, this will occur with any two forms on a page, because they both have a form id, and the id given by form api (
edit-form_id) is duplicated. The same goes for two forms which use form tokens: the hidden token field will also collide.However, only the 'name' attribute matters for form submission and it is not required to be unique. The 'id' has been used for JS/AJAX purposes (and CSS, I guess). We've been giving them different values for ages:
name="edit[form_id]" id="edit-form_id", so there is no problem in changing the id to be unique.Patch attached which modified the #id attribute of the standard form API hidden fields by appending the $form_id (and fixes some bad code style).
I tested it with the login block, search block and theme search form on one page. They all work fine.
Comment #2
Steven commentedComment #3
alexmarkley commentedFor what it's worth, I just patched my site, and it works like a charm! Thanks, Steven! :)
Comment #4
Jaza commentedWorks fine for me too. Like Steven said, the id isn't part of form submission, and I'm not seeing that the change breaks anything that makes use of the id. +1, and I think it's ready.
Comment #5
dries commentedWhy do we mix - and _? Can't we get rid of the ugly "form_id" to begin with?
Comment #6
archetwist commentedhttp://drupal.org/node/40486
Comment #7
dries commentedComment #8
fgmJust a reminder: another fix has been discussed on http://drupal.org/node/63516, which is now marked as duplicate of this one to merge both.
Here it is again.
Comment #9
killes@www.drop.org commentedThe latest patch makes sense to me. Any other opinions?
Comment #10
drummCommitted to HEAD.
Comment #11
Bèr Kessels commentedGerhard asked about some feedback to backport this issue.
The only possible problems Gerhard pointed to, are related to Javascript and CSS. However, both JS and CSS require unique IDS to properly function. So, if a CSS design falls apart because we now have unique IDs, that is only because in the previous state, the CSS "acted wrong" anyway. JS, AFAIK always prompts an error when it tries to use an ID that appears more then once.
So: I don't see a big problem. Since we will only fix the CSS and JS usage, instead of breaking it.
What I cannot really see from the patch, is, if all CSS ids with these two specific ids will change, or if only those that appear twice, are to be changed. If its the first, then we will introduce some problems, but if its the latter, we only fix existing problems, and not introduce any new ones.
Comment #12
killes@www.drop.org commentedstr_replace('_', '-', "edit-$form_id")
That is the transformation which is executed. That is all _ will be replaced by -. This affects all form IDs for hidden fields.
What now?
Comment #13
killes@www.drop.org commentedapplied to 4.7.
Comment #14
(not verified) commentedComment #15
damaikar-at-sgprojx.com.au commentedHi folks,
Drupal Newbie (yesterday), CMS Newbie (last week:-P)...I hope this doesn't scare you too much.
I just wish to know WHERE exactly I should place this patch-code....i.e. In which file?
This may be glaringly obvious to you, and I apologise for dumb question, but it is not obvious to me at all...yet:-P
Many thankss
Stephen G
response - mailto:sg@sgprojx.com.au