Duplicate id attributes for submit buttons in Drupal 5.x

Drupal 5 doesn't generate unique id attributes for form submit buttons. This means that if there's both a login form and a search box on the same page they will both use the same edit-submit id causing the page to fail validation.

This has been . You can solve it in Drupal 5 by inserting the following into template.php:

* Quick fix for the validation error: 'ID "edit-submit" already defined' or edit-name
* There is a solution in d6 core: http://drupal.org/node/111719
function phptemplate_submit($element) {
   static $count_double_id=0;

  $tmp = str_replace('edit-submit', 'edit-submit-'. $count_double_id++, theme('button', $element));
  return str_replace('edit-name', 'edit-name-'. $count_double_id++, $tmp);

(Snippet by )


Thanks a lot man. Being a validation fanatic this is exactly what I was looking for ;)

Thanks! It was the last-last piece to validation! :)

Thanks, Thanks, Thanks, Thanks... ;)

I’m glad to know your write-up. As a support this is accurately what I was gazing for.

Post new comment

The content of this field is kept private and will not be shown publicly.
(I add rel="nofollow" to the link, so hold the spam)
No HTML allowed. Please use syntax to format content.