gregmuellegger / django-superform

Add forms and formsets to other forms like they were fields.

Home Page:http://django-superform.readthedocs.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add better validation support for nested fields

gregmuellegger opened this issue · comments

An example syntax:

class MyForm(SuperForm):
    addresses = FormSetForm(...)

    def clean_addresses(self):
        data = self.formsets['addresses'].cleaned_data
        raise ValidationError('...')  # will end up in self.errors['addresses']
        return data  # I would suggest ignoring the returned data as it's not clear were it should end up.

    def formsets_clean(self):
         ... # maybe another solution to clean multiple formsets at once together. The name cannot be clean_formsets as this might clash with a field called "formsets".