On Mon, Jun 30, 2008 at 10:44 PM, Simon Li <[EMAIL PROTECTED]> wrote:

>
> Hi Guys;
>
> I use Django newforms,I met a problem
>
> UserRole=(['admin','administrator'],['user','Normal User'])
> user_role =
>
> forms.CharField(widget=forms.RadioSelect(choices=UserRole),error_messages={'required':u'You
> must choose one!'})
>
> the code is rendered to html is:
>
> <ul><li><label><input type="radio" name="user_role" value="admin" />
> Administrator</label></li>
> <li><label><input type="radio" name="user_role" value="user" /> Normal
> User</label></li>
> </ul>
>
>
> I do NOT like the <ul><li> etc, I hope it can be rendered to simple
> format,
> <label><input type="radio" name="user_role" value="admin" />
> Administrator</label>
> <label><input type="radio" name="user_role" value="user" /> Normal
> User</label>
>
> I want to get ride of the <ul><li>, could you guys help me?
>

Create your own custom widget (based off RadioSelect) that specifies your
own custom renderer (based off django.newforms.widgets.RadioFieldRenderer)
and overrides the render() method to do what you want.  For an example, the
newforms-admin code does this here:

http://code.djangoproject.com/browser/django/branches/newforms-admin/django/contrib/admin/widgets.py#L69

Karen

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