Hi. I already asked this question in StackOverflow, but I didn't get any 
useful answer. Let's try here :-)

I have a BaseInlineFormSet, and I'd like to validate a field in the parent 
form based on the values on the fields of the children. As seen in the 
docs, the only method to make a custom validation is clean(), but I can't 
find a way to add errors to the parent form, only for the children.

In the following code I build a formula. Each variable comes from a inner 
form, and if the global formula don't validate, I'd like to add an error to 
the parent's form field formula

class CustomInlineFormSet(BaseInlineFormSet):
    def clean(self):
        formula = self.instance.formula
        variables = []
        for form in self.forms:
            if 'formula_variable' in form.cleaned_data:
                variables.append(form.cleaned_data['formula_variable'])

        valid, msg = validate_formula(formula, variables)
        if not valid:
            WHAT HERE???

Thank you!!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/87ce32a8-782e-4248-8b8c-046b6eef0904%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to