I don't think that is possible.  When you reference the field inside
the template (with form.my_field) you are accessing a BoundField that
is tied to the formfield in question.  From this BoundField you don't
actually have access to the widget.  Rather you call as_widget or
as_hidden (or __unicode__ which calls as_widget).  I don't see any way
in there to access anything that I add to my widget.  Even if I could
access the widget directly, I wouldn't have the data to render since
that is in the BoundField.  It seems to me that the only way to get
this to work is to make changes to BoundField (maybe adding some
BoundWidget class even) to allow you to get sub-widgets out of a
MultiWidget.  Otherwise there simply isn't any way to access the sub-
widget while also passing the data and attrs to that widget.

-Paul

On Jun 14, 12:32 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Thu, 2007-06-14 at 00:12 +0000, Paul wrote:
> > Is this possible?  The old forms module allowed you to render the date
> > and time separately in the template for the form.  Now it seems this
> > is no longer possible.  So it isn't possible for instance to render
> > the date on one row of a table and the time on the following row just
> > below it like:
> > <tr><td>{{form.blah}}</td><td>{{form.mydate.date}}</td></tr>
> > <tr><td>{{form.blah2}}</td><td>{{form.mydate.time}}</td></tr>
>
> It's not possible with the default SplitDateTime widget, but it would be
> easy enough to subclass it to provide the functionality you want.
> Newforms are designed around encouraging people to subclass things as
> they need to add new features, rather than trying to provide everything
> by default (which becomes too difficult to use in the common cases).
>
> Create a SplitDateTimeWidget subclass and add date() and time() methods
> that return the respective widgets (would replicate some of the logic in
> MultiWidget.render)
>
> Or your could write a patch for MultiWidget that allowed access to the
> n-th widget in the sequence and post that to Trac. I can't think of
> another generic method on MultiWidget that would help, since it's meant
> to be able to handle an arbitrary number of contained values, not just
> the date+time case.
>
> Regards,
> Malcolm


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to