This is a known issue but I though I should just get this up here to point out another situation where there are dupicate id attributes breaking w3c validation.

The search button id and the comment controls button both have an id of "edit-submit". It's due to how form api works. Not a big deal but if anyone wants to get around this, you can create a theme override and manually change property.

example:

function phptemplate_comment_controls($form) {

  // Override submit button id. was 'edit-submit'.
  $form['submit']['#id'] = 'comment-controls-submit';

  $output .= '<div class="container-inline">';
  $output .=  drupal_render($form);
  $output .= '</div>';
  $output .= '<div class="description">'. t('Select your preferred way to display the comments and click "Save settings" to activate your changes.') .'</div>';
  return theme('box', t('Comment viewing options'), $output);
}

Related to this issue:
http://drupal.org/node/87708
http://drupal.org/node/71615
http://drupal.org/node/47785
http://drupal.org/node/71615
http://drupal.org/node/111719

Comments

dvessel’s picture

A more generalized approach.. this ID pops up in many places.

function phptemplate_submit($element) {
  static $dupe_ids = array();
  // Prevent duplicate id's.
  if (isset($dupe_ids[$element['#id']])) {
    $dupe_ids[$element['#id']] = $dupe_ids[$element['#id']] + 1;
    $element['#id'] = $element['#id'] .'-'. $dupe_ids[$element['#id']];
  }
  else {
    $dupe_ids[$element['#id']] = 0;
  }
  return theme('button', $element); 
}

Something to use until it's fixed in core.

alexmarkley’s picture

The whole "auto-generated form ids aren't unique enough" problem is pretty serious for me, so I'm subscribing to this issue. (The only intelligent thing I have to say about this family of issues.)

chx’s picture

Status: Active » Closed (duplicate)