Opened 8 years ago
Closed 8 years ago
#29011 closed Cleanup/optimization (wontfix)
forms.Field with space in dynamically generated forms.Form leads to wrong assigned id in generated HTML form
| 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 (last modified by )
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. Maybe everything should be underscored? At least the doc, which references id_<field-name>, should be improved (also present in 2.0 doc)
Change History (2)
comment:1 by , 8 years ago
| Description: | modified (diff) |
|---|
comment:2 by , 8 years ago
| Resolution: | → wontfix |
|---|---|
| Status: | new → closed |
| Type: | Uncategorized → Cleanup/optimization |
Note:
See TracTickets
for help on using tickets.
I don't see a strong argument for making a change here. If you're generating field names that aren't valid when using a normal declarative form, you're on your own. I don't think this is a normal use case that needs documentation.