Opened 18 years ago

Closed 17 years ago

#4005 closed (duplicate)

Add "class=<field name>" attribute to generated inputs

Reported by: tonnzor <tonn81@…> 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 Simon G. <dev@…>, 18 years ago

Triage Stage: UnreviewedDesign decision needed

comment:2 by Terry, 18 years ago

+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.

comment:3 by anonymous, 17 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 anonymous, 17 years ago

Resolution: wontfix
Status: newclosed

comment:5 by Chris Beaven, 17 years ago

Resolution: wontfix
Status: closedreopened

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 James Bennett, 17 years ago

Resolution: duplicate
Status: reopenedclosed

The attrs trick is one solution, but either #3515 or #3512 would solve the underlying problem of automatically marking things in the HTML.

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