Opened 8 years ago

Last modified 8 years ago

#27565 closed Bug

{{ form.as_p }} with RadioSelect generates invalid HTML — at Version 1

Reported by: Maciej Olko Owned by: nobody
Component: Forms Version: 1.10
Severity: Normal Keywords: RadioSelect, invalid html, ul
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: yes

Description (last modified by Maciej Olko)

When working with forms, RadioSelect with {{ form.as_p }} renders to:

<p>
    <label for="…">…</label>
    <ul id="…>
        <li><label for="…"><input id="…" name="…" type="radio" value="…" required /> …</label></li>
        <li><label for="…"><input id="…" name="…" type="radio" value="…" required /> …</label></li>
        …
    </ul>
</p>

which is invalid. Vide http://stackoverflow.com/questions/10601345/ul-element-can-never-be-a-child-of-p-element .
It should render to:

<p>
    <label for="…">…</label>
</p>
<ul id="…>
    <li><label for="…"><input id="…" name="…" type="radio" value="…" required /> …</label></li>
    <li><label for="…"><input id="…" name="…" type="radio" value="…" required /> …</label></li>
    …
</ul>

Change History (1)

comment:1 by Maciej Olko, 8 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top