#13564: Provide class attributes for form fields
-------------------+--------------------------------------------------------
Reporter: h3 | Owner: nobody
Status: new | Milestone: 1.3
Component: Forms | Version: 1.2-beta
Keywords: | Stage: Unreviewed
Has_patch: 0 |
-------------------+--------------------------------------------------------
I work a lot with Django forms and I'm also working on grappelli and I've
come to find that there's one thing that is cruelly missing from django's
forms..
Meaningful class names on form inputs.
As now if I want to change the class name of an input I either have to
write the forms explicitly or do something like this for *every* forms:
{{{
from django import forms
from django.forms import widgets
class MyForm(forms.Form):
title = forms.CharField(required=True,
widget=widgets.TextInput(attrs={
'class': 'charfield required'
}))
}}}
Whereas it would be easy to simply use the field type's name to generate a
meaningful class;
{{{
<input type="text" value="" class="django-charfield django-required" />
}}}
The "required" is not crucial, but would be really useful for JavaScript
enhanced validation.
That said, just a class hinting the field type would be a 100%
improvement.
Finally, it's not just for JavaScript. It would also be useful for CSS
styling. For example when
I use a PositiveInteger field I never need it to be the same width as a
Char field. It would
be nice to be able to style them without having to write many lines of
Python or HTML codes.
--
Ticket URL: <http://code.djangoproject.com/ticket/13564>
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.