#13564: Provide class attributes for form fields
------------------------------------+---------------------------------------
Reporter: h3 | Owner: trebor74hr
Status: assigned | Milestone:
Component: Forms | Version: 1.2-beta
Resolution: | Keywords:
Triage Stage: Accepted | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 |
------------------------------------+---------------------------------------
Comment (by trebor74hr):
Replying to [comment:13 julien]:
> Feel free to create a new ticket for (2) and mention #13564 as a related
ticket.
I'm still not convinced that (2) should be created as ticket at all.
Automatically filling css properties of fields/widgets is backward
incompatible change, and therefore could cause problems. On the other
hand, I use django.forms a lot, and in the cases like (2) is, I create my
own base Form class (by inheriting django.forms.Form) and put all common
functionality in there. Then I inherit this Form. Example for (2):
{{{
from django import forms
class Form(forms.Form):
def get_field_css_classes(self, bf, css_classes):
css_classes.add("django-%s" % bf.field.__class__.__name__.lower())
return css_classes
class UserRegistrationForm(Form):
...
}}}
My suggestion is to solve only (1) and (2) could serve as example in
documentation like explained.
btw. I don't know if regular django user takes advantages of creating own
customized Forms/Widgets/Fields + inheritance, but I have a feeling that
this is not very often the case. If this is true, then I suggest stronger
promotion of this powerful django feature. For the start, such approach
could be (more) emphasized in the official django documentation (with
examples).
--
Ticket URL: <http://code.djangoproject.com/ticket/13564#comment:14>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.