Invalid IDs and names used in HTML for option groups

Create issue
Issue #1010 new
Former user created an issue

In detail_configurableproduct.html, line 59, a select element is created for each option_group in options with the following attributes:

name="{{ }}" id="{{}}"

(Minor note: it's annoying that one variable uses the correct space between brackets and variable name and the other doesn't)

This will resolve to something like: name="1" id="1" which is invalid HTML. The W3C standards for HTML state clearly that both name and id must start with a letter, not a number.

Unfortunately this can't be changed simply in an overriding template because the function optionids_from_post in product.views looks for elements like: if POST.has_key(str(

...which means the product will never be added to the cart.

We're using Python so I expect that the argument of "well, it works doesn't it?" won't be used by anyone in defense of the current code. :) There is a large amount of HTML throughout Satchmo templates that is, for lack of a better word, "poor" and not compliant with web standards. This issue is different though, because it cannot be resolved with an overriding template.

It could easily be fixed if line 42 of product.views.init were such:

if POST.has_key('opt_grp%s' % str(

... and the template were changed to correspond.

Comments (3)

  1. Chris Moffitt repo owner

    Thanks for the ticket. To be honest, I didn't know that the HTML spec had this requirement. I guess you learn something new every day :)

    If I understand correctly, I'm ok with the proposed change. If you submit a patch, I'll look at it and apply.

    As far as you other comments about HTML standards, I'm sure you're right. I'm not an HTML standards expert so I'll be happy to apply patches or assist with the cleanup.

  2. Log in to comment