Hi,
I need your help regarding webform.
I checked with a html validator my website and webform creates many errors and seems to be not w3c conform.
Webform makes basically 2 errors:
1. It writes symbols like / & () within an id-class which is not allowed.
2. It gives ID classes more than one. Even so I just have one webform formular (as a block) on a site it has two same ID classes as the search form also uses the same class.
To make my point clear I attached the errors of one of my site.
line 206 column 35 - Fehler: ID "edit-submit" already defined
line 152 column 35 - Info: ID "edit-submit" first defined here
line 248 column 61 - Fehler: ID "edit-details-email-subject" already defined
line 200 column 61 - Info: ID "edit-details-email-subject" first defined here
line 249 column 57 - Fehler: ID "edit-details-email-from-name" already defined
line 201 column 57 - Info: ID "edit-details-email-from-name" first defined here
line 250 column 60 - Fehler: ID "edit-details-email-from-address" already defined
line 202 column 60 - Info: ID "edit-details-email-from-address" first defined here
line 254 column 35 - Fehler: ID "edit-submit" already defined
line 152 column 35 - Info: ID "edit-submit" first defined here
line 269 column 101 - Fehler: character "&" is not allowed in the value of attribute "id"
line 270 column 72 - Fehler: character "&" is not allowed in the value of attribute "for"
line 270 column 214 - Fehler: character "&" is not allowed in the value of attribute "id"
line 272 column 69 - Fehler: character "/" is not allowed in the value of attribute "id"
line 273 column 70 - Fehler: character "/" is not allowed in the value of attribute "for"
line 273 column 206 - Fehler: character "/" is not allowed in the value of attribute "id"
line 275 column 76 - Fehler: character "(" is not allowed in the value of attribute "id"
line 276 column 77 - Fehler: character "(" is not allowed in the value of attribute "for"
line 276 column 235 - Fehler: character "(" is not allowed in the value of attribute "id"
line 289 column 61 - Fehler: ID "edit-details-email-subject" already defined
line 200 column 61 - Info: ID "edit-details-email-subject" first defined here
line 290 column 57 - Fehler: ID "edit-details-email-from-name" already defined
line 201 column 57 - Info: ID "edit-details-email-from-name" first defined here
line 291 column 60 - Fehler: ID "edit-details-email-from-address" already defined
line 202 column 60 - Info: ID "edit-details-email-from-address" first defined here
line 295 column 35 - Fehler: ID "edit-submit" already defined
line 152 column 35 - Info: ID "edit-submit" first defined here
Many thanks. Maybe you can tell me how to fix it or if its planned to fix it.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | webform_unique_ids6.patch | 21.46 KB | quicksketch |
| #11 | webform_unique_ids7.patch | 18.31 KB | quicksketch |
| #7 | webform_unique_ids6.patch | 21.3 KB | quicksketch |
| #7 | webform_unique_ids7.patch | 17.33 KB | quicksketch |
Comments
Comment #1
quicksketchAll of the ID errors will not be fixed, as they are caused by showing multiple Webforms on the same page. Putting Webforms in blocks is not technically supported, which reduces the likelyhood of this happening. However characters should be stripped out of IDs, I'm surprised that they're showing up there. Could you describe what settings cause those symbols to show up in the IDs?
Comment #2
chris_bbg888 commentedHi quicksketch,
I just can describe it from a not technical point of view.
I do a webform with the type "select". For the options I enter somethink like "Website & Grafik" (without the WYSIWYG Editor) or "Search engine (like Google ..)". So I get these symbols ()& in the Webform which results in an html error.
For the second part:
Even if I have a search field and a webform on one website I get one error. For me I get many errors as I use webform as blocks for short surveys. hmm can I avoid it somehow that get always the same IDs?
Thanks
Comment #3
DoubleT commentedI have a similar validation problem with fieldsets. After duplicate a fieldset, all fields within these fieldset gets the same field name and therefore the same ID. I have to change all field name to get the ID unique.
It would be better, if the name of the fieldset would be part of the ID of these fields.
e.g.
fieldset family - id="webform-component-_family"
fieldset father - id="webform-component-_family_father"
field firstname - id="webform-component-_family_father-firstname"
field lastname - id="webform-component-_family_father-lastname"
fieldset mother - id="webform-component-_family_mother"
field firstname - id="webform-component-_family_mother-firstname"
field lastname - id="webform-component-_family_mother-lastname"
fieldset firstchild - id="webform-component-_family_firstchild"
field firstname - id="webform-component-_family_firstchild-firstname"
field lastname - id="webform-component-_family_firstchild-lastname"
and so on...
I also miss a class to style for example, all firstname like class="webform-component-firstname"
Comment #4
philpro commentedI am also experiencing this validation error. Special characters are not being stripped out and are being rendered within the id tags and for tags on the input form items. This validation error does not appear to be occurring in a previous (2.6) version that I've installed within another site.
Please advise.
Comment #5
DoubleT commented@quicksketch
Please, could you answer anything to the fieldsets thing?
Did i miss something, or is there something wrong in my post?
Or will it be part of 6.x-.3.0?
Comment #6
quicksketchThe nesting of elements inside of fieldsets should in fact generate a new class name (reflecting the full nested path). The trouble being we don't currently have any way of getting an elements parents at the point when a component is rendered. It's definitely a bug of sorts though, just one I'm not sure how we should fix.
Comment #7
quicksketchAn idea came to me that we could create the ID of these elements after they have been rendered, since the parents have already been calculated at that point. In the 3.x branch we have a useful back-port of the #theme_wrappers property, which makes this easy to accomplish. The Drupal 7 version is even simpler, since we don't need a "wrapper" at all, because we can override the use of theme_form_element() and just replace the wrapper added by Drupal core. So in short, here's what our output will look like in these two versions:
Drupal 6: (same as the current output, other than the ID is nested now)
Drupal 7: (merge the wrappers, as is only possible in Drupal 7)
Comment #8
quicksketchConsidering this could have a large impact on existing CSS, and because this would take significantly more work in the 2.x branch, this fix will only go into the 3.x version.
Comment #9
DoubleT commented@quicksketch
Cool, thank you for the patch!
Will test it, but need some time. I haven't yet a test system with 3.x version of webform.
Comment #10
quicksketchIt's too bad this wasn't in the original 3.x final release. I'm still very keen on including this change, since it opens up opportunities for much better control over theming in Drupal 7.
Comment #11
quicksketchPatch rerolls, these seem pretty good to me, just a bit more testing necessary.
Comment #12
quicksketchI've committed these patches. They will be included in the 3.3 release.