On Wed, 2009-06-03 at 14:28 -0700, LaundroMat wrote:
> Hi -
> 
> I'm trying to change the way a ChoiceField (with widget =
> forms.RadioSelect) is being rendered in a template. Currently,
> rendering the form as_p() for instance, will return HTML such as:
> <ul>
> <li><label for="id_type_0"><input type="radio" id="id_type_0"
> value="1" name="type" />choice 1</label></li>
> <li>...</li>
> </ul>
> 
> Is there a way to control how this ChoiceField is rendered? I'd like
> to use something else than an unordered list...
> 
> Many thanks in advance,
> 
> Mathieu

The RadioSelect widget takes an optional keyword argument 'renderer'
which allows you to pass in a custom class type to use as your renderer.

Your class should have a render() method, and accept the same
constructor arguments as the default RadioFieldRenderer - name, value,
attrs, choices. Check out django/forms/widgets.py for the gory details.

Tom


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" 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-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to