IDs are set on a few form elements. Although I believe they should be rather removed, as for most parts they are automatically assigned in the form generation and they do not need to be that specific, because you can target any of those in JS/CSS differently, if you want to keep them at least is worth passing them through drupal_html_id() to be sure those IDs are going to be unique.

This was a problem for me specially when the form of an add to cart product was rendered twice in a page (two different blocks) which could sometime happen eventually on a site.

I am working on a new ajax cart alternative (pretty stable, so will soon release it: https://drupal.org/sandbox/hanoii/2247395) and because it uses the internal drupal AJAX framework, this uniqueness of IDs was a must.

I sorted it out in my module's alterer:

    // Because we can have the form more than one in a page, makes sure
    // the ajax id element of the submit element is the same.
    $form['actions']['submit']['#id'] = drupal_html_id($form['actions']['submit']['#id']);

But worth including this in ubercart. I let you decide though, if it's not better to just remove the '#id's all together.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hanoii’s picture

Status: Active » Needs review
FileSize
2.34 KB
longwave’s picture

Not sure why we set those IDs directly. Wonder if we can safely remove this entirely?

hanoii’s picture

I actually thought of that and for a reason I can't seem to remember I concluded it wasn't that safe to remove, but not entirely sure of why. Maybe some JS is after those IDs?

EDIT: re-reading the summary it seems that it was safe to remove them, as I mentioned about that possibility in the issue summary. There are only a few so I guess you could just remove it and do a few quick tests.

anrikun’s picture

+1 for removing these #id

anrikun’s picture

This patch removes these #id.