But the problem is that the clean() method of the field already throws
a validationError, though i actually dont need to validate this field.
And that method simply comes first, no way around using the various
clean methods :-(

wolfram

On Nov 23, 2007 2:32 PM, Manakel <[EMAIL PROTECTED]> wrote:
>
> Maybe you can remove the logic from the Field cleanMethod and add it
> to the Form CleanMethod.
> because i understand you want a validation based on the content of
> several fields ?
>
> I would try something like this:
> - in Field "clean" method: validate data nature
> ie mail address is really a mail adress ([EMAIL PROTECTED]) (technical logic)
> - in Form "clean_Field" method: valid data integrity
> ie mail adress is a mail adress of a registered user  (business unit
> logic)
> - in Form "clean" method : validate data consistency with other
> fields
> ie i set the status to "assigned" only if there is a "resolution
> group" defined (business Form Level logic)
>
> But i had no time to test right now
>
> On Nov 23, 2:05 pm, "Wolfram Kriesing" <[EMAIL PROTECTED]>
> wrote:
>
> > I got an alike problem, I ran through the docs, mailing lists, etc.
> > but no solution.
> >
> > I got:
> >
> > class LinkForm(forms.Form):
> >     TYPE_CHOICES = (
> >         ('user', _('User link')),
> >         ('url', _('Web link')),
> >     )
> >     type = forms.ChoiceField(choices=TYPE_CHOICES)
> >     user = forms.IntegerField(required=False)
> >     url = forms.URLField(required=False, initial='http://')
> >
> > I want to validate the url-field _only_ when the type-field is set to
> > "url" otherwise I don't, and I also don't want to get errors thrown
> > otherwise!
> > But since the Field's clean() method is called first the URL always
> > gets validated :-(
> > So I have no chance to modify the url-Field to an empty string using
> > the various clean-methods.
> >
> > Is overriding the __init__() and putting the logic in there my only chance?
> > Or did I miss something here?
> >
> > --
> > cu
> >
> > Wolfram
>
> >
>



-- 
cu

Wolfram

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