List Info

Thread: Re: MultiValueField and labels




Re: MultiValueField and labels
country flaguser name
Australia
2008-02-24 01:08:06

On Sat, 2008-02-23 at 21:21 -0800, Zack wrote:
[...]
> Why doesn't
> >>> f = TestPersonForm()
> >>> f.as_p()
> have labels generated for all the CharFields as defined
in
> PersonField?

Because that's not how MultiWidget works.

You can see from the code that the labels on widgets are
created by the
Form._html_output() method, not by the widget rendering
methods (which
makes sense, as often the label side of things is changed).
You can also
see that MultiWidget's rendering method just calls the
rendering method
on each of its sub-widgets.

If you want your sub-fields to render with labels and
everything, make
them separate fields and then use the form's clean() method
to combine
their individual values back into a single value (since
Form.clean() is
designed for normalising values that come from multiple
fields).

Regards,
Malcolm

-- 
Tolkien is hobbit-forming. 
http://www.pointy-s
tick.com/blog/


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )