On 12/9/06, Brian Victor <[EMAIL PROTECTED]> wrote:
One of the things I was hoping for in newforms but haven't found is a
way to do a composite form field that uses multiple <input> elements
that reduce to a single python object. E.g.,
>>> class MyForm(Form):
... postdate = CompositeField(ChoiceField(choices=['Jan', ...]),
... ChoiceField(choices=range(1,32)),
... ChoiceField(choices=range(2000,2010)))
...
>>> str(MyForm())
'<tr><td>Postdate</td><td><select name="postdate1"><option>Jan</option>'
(and so forth, with select fields for all three before closing the td/tr))
Merry Christmas! In changeset [4236], I've implemented this as
django.newforms.extras.SelectDateWidget. See the new unit tests for
example usage:
http://code.djangoproject.com/changeset/4236
I still need to add unit tests that demonstrate how the value is split
into three HTML fields but combined into a single datetime.date object
by the widget value_from_datadict() method.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---