Hi all,
Let's assume i have to the following simple form:
class Form(forms.Form):
check = forms.BooleanField(
required=False,
)
# take into account only when 'check' is True
len = forms.IntegerField(
min_value=3,
max_value=5,
required=True,
)
What I want is to validate the 'len' field only when 'check' is True.
I could define the clean method of the form and validate the required,
min_value and max_value stuff only when 'check' is True but the case when
someone types a non integer value into the input is still there. How
could I skip that? That check is done by the IntegerField.
The best would be to simply remove the 'len' field of the form when
'check' is False.
Maybe I could examine request.POST in form's __init__ and according to
it's content remove the fields I don't care about.
Or is that a terrible idea?
bests
Zoli
--
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
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.