Hi everyone,
In a formset I can use the .clean() method to validate data across the formset. The formset.clean() method is run after all the form.clean() methods - this makes sense. Raising a formset ValidationError alerts the user to the problem with formset.non_form_errors.
I would like to also set an error condition on one of more of the individual forms as a result of this formset validation failure to help identify the location of the problems (my formsets can be quite long and this will help guide the eye). I've spent quite a lot of time looking for such an example with no success. Is there a way I can do this?
Here's some pseudo-code to outline what I want to do:
call MyFormSet(BaseFormSet):
def clean(self):
super(MyFormSet, self).clean()
# validation code goes here...
if some_validation_error:
raise ValidationError(...) # creates the formset error message
create_error_in_identified_forms(somehow) # <<<< I want to know how to do this bit
Thanks & best wishes!
R.