Opened 7 years ago

Last modified 7 years ago

#29011 closed Cleanup/optimization

forms.Field with space in dynamically generated forms.Form leads to wrong assigned id in generated HTML form — at Initial Version

Reported by: pdehaye Owned by: nobody
Component: Forms Version: 1.11
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

If you do:

import django
from django.forms import Form
from django.forms import CharField
PersonForm = type('Person', (Form,), {"work address":CharField(max_length=128)})
person = PersonForm()
person.as_ul()

You get

'<li><label for="id_work address">Work address:</label> <input type="text" name="work address" maxlength="128" required id="id_work address" /></li>'

I think the id="id_work address" is suboptimal here. At least the doc, which references id_<field-name>, should be improved (also present in 2.0 doc)

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top