Opened 18 years ago
Closed 17 years ago
#4005 closed (duplicate)
Add "class=<field name>" attribute to generated inputs
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Design decision needed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
It would be very useful if each generated input was marked - what kind of data it contains. Then it is possible to improve the look and feel of elements via CSS or JS.
For example, if all newforms.IntegerFields has 'integer' class, it would be easy to align text to the right, make the font monospace, decrease the size, etc.
If the bug is approved, I can write a patch.
Change History (6)
comment:1 by , 18 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:2 by , 18 years ago
comment:3 by , 18 years ago
This is possible with attrs for the widget, which makes sense, since the widget is associated with how the field looks. For example:
my_int = newforms.IntegerField(label = "Your income in cold cash", widget = forms.TextInput(attrs={'class': "Income dollars"}), )
You can pass any dictionary for attrs, so dynamically determining and specifying attributes is easy.
comment:4 by , 18 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
comment:5 by , 18 years ago
Resolution: | wontfix |
---|---|
Status: | closed → reopened |
anonymous, don't close tickets thanks - that's a job for one of the ticket managers.
Specifically, you're missing the point in this ticket which is to automatically add the field's identity to the class attr (like oldforms does with vHidden
, vTextArea
, etc)
comment:6 by , 17 years ago
Resolution: | → duplicate |
---|---|
Status: | reopened → closed |
+1 for this change.
IMO it should be done as an optional string in the Fields initiation parameters called 'class', e.g.
My_int = newforms.IntegerField(label="Your income in cold cash", class="Income dollars")
This would allow quite some flexibility when styling the form.