Re: Suppressing field in template for ChoiceField with only one option.

2010-09-29 Thread Shawn Milochik
On Sep 29, 2010, at 5:08 PM, aa56280 wrote: > Can't you specify the value using the initial argument? > http://docs.djangoproject.com/en/dev/ref/forms/fields/#initial > > I did that originally, but it doesn't show up when the HiddenInput renders. That's why I stopped changing the widget. Sh

Re: Suppressing field in template for ChoiceField with only one option.

2010-09-29 Thread aa56280
Can't you specify the value using the initial argument? http://docs.djangoproject.com/en/dev/ref/forms/fields/#initial On Sep 29, 3:33 pm, Shawn Milochik wrote: > Actually, I spoke too soon on this one. My original solution doesn't work > because the hidden input on the form doesn't have a valu

Re: Suppressing field in template for ChoiceField with only one option.

2010-09-29 Thread Shawn Milochik
Actually, I spoke too soon on this one. My original solution doesn't work because the hidden input on the form doesn't have a value, so the form won't validate. I fixed this by just adding display: none to the widget attrs in the __init__ instead of changing the widget to a HiddenInput. Now the

Re: Suppressing field in template for ChoiceField with only one option.

2010-09-29 Thread aa56280
That seems pretty straightforward me. You want to customize the form based on the user and so you're doing it when the form is initialized. Makes perfect sense. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Suppressing field in template for ChoiceField with only one option.

2010-09-29 Thread Shawn Milochik
I ran into an interesting forms issue today which I came up with a solution for. Now I'm wondering if there's a better way. Situation: I have a forms.Form with several fields in it, including a ChoiceField. The values in this ChoiceField are dependent on what the user has access to. Many users