I get this XHTML error in SGML / Tidy validator:

line 1069 column 46 - Error: value of attribute "id" invalid: "6" cannot start a name
<input type="hidden" name="form_build_id" id="694cceb8d936f9cbe0b0e1f2ff27129f" value="694cceb8d936f9cbe0b0e1f2ff27129f"  />

Comments

jadwigo’s picture

this is fixed for drupal 6.x http://drupal.org/node/145135#comment-557450

but it might be nice to include this in the next drupal 5.x update too

(just change line 55 of form.inc to $form_build_id = 'form-'.md5(mt_rand()); if you need a quick fix)

function drupal_get_form($form_id) {
  // In multi-step form scenarios, the incoming $_POST values are not
  // necessarily intended for the current form. We need to build
  // a copy of the previously built form for validation and processing,
  // then go on to the one that was requested if everything works.

  $form_build_id = 'form-'.md5(mt_rand());
  if (isset($_POST['form_build_id']) && isset($_SESSION['form'][$_POST['form_build_id']]['args']) && $_POST['form_id'] == $form_id) {
    // There's a previously stored multi-step form. We should handle
    // IT first.
....
mr.baileys’s picture

Bump. Are bug fixes still applied against 5.x-dev? Or are changes limited to security fixes?

If this has no chance of making it into 5.x-dev anymore, I guess it should be marked "won't fix".

mr.baileys’s picture

Issue tags: +XHTML validation

Tagging.

sun’s picture

Title: form_build_id starts with invalid number in name » ID attribute of form_build_id input element contains invalid characters
Version: 5.x-dev » 7.x-dev

Still an issue in D7. The 'id' attribute shouldn't exist in the first place here.

Robatron’s picture

Version: 7.x-dev » 5.x-dev
Status: Active » Needs review
StatusFileSize
new873 bytes

Here's a patch for the fix jadwigo described above for the 5.x-dev version.

I should add that this is my first patch submission to Drupal, so if I manage to screw up this bug report by posting, or if I'm not posting in the correct manner, or my patch isn't in the correct format, etc. I apologize :-)

hass’s picture

Version: 5.x-dev » 7.x-dev
Status: Needs review » Active
sun’s picture

Title: ID attribute of form_build_id input element contains invalid characters » ID attributes of hidden form input elements contain invalid characters (kill 'em)

Better title.

We just want to remove the ID attribute from all hidden form elements. Simple. They make no sense at all, as you cannot style hidden input elements, and you can easily access them via jQuery attribute selectors. I can only guess that those IDs date back to Drupal 4.7, when we only had our custom $() JavaScript function to select DOM element #ids in the markup.

sun’s picture

Issue tags: +DIE

hah, forgot that tag

sun’s picture

Title: ID attributes of hidden form input elements contain invalid characters (kill 'em) » Hidden input elements contain invalid characters in ID attributes (DIE)
Status: Active » Needs review
StatusFileSize
new685 bytes

There's absolutely no need for those IDs and no reason to keep those IDs.

So let's fix a bug, and additionally vastly decrease the markup length.

If anyone still needs an ID attribute on a hidden element, one can still assign #attributes][id just fine. Just no auto-generated IDs.

Did not remove the #id assignments in drupal_prepare_form(), because the #id properties for the required hidden Form API elements are constructed in a special way. If, for some reason, someone would like those to appear as in D6 and below, one can write a hook_form_alter() that simply does $element['#attributes']['id'] = $element['#id'] for one or all of those elements.

bleen’s picture

StatusFileSize
new800 bytes

them_hidden has changed since August...

On one hand, the error pointed out in the original post no longer exists (it appears that IDs are preprended with 'form-' (or similar) so there wont ever be an id starting with a numeral), on the other hand there is still no compelling reason to have the ID appear at all ...

So as long as we're here, lits just kill it and make the markup more better...

re-roll attached

sun’s picture

Title: Hidden input elements contain invalid characters in ID attributes (DIE) » Hidden input elements contain invalid characters in ID attributes
Status: Needs review » Reviewed & tested by the community

The IDs get still generated, but I think that's OK + eventually allows someone to safely take over #id into attributes][id.

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks.

Status: Fixed » Closed (fixed)
Issue tags: -XHTML validation, -DIE

Automatically closed -- issue fixed for 2 weeks with no activity.