On Thu, 2009-03-12 at 10:57 +0100, Thomas Guettler wrote: > Hi, > > I often have several forms in on <form> tag. Like FormSet, > it would be nice to have a class which combines several forms. > > But FormSet can only deal with several forms of one class. > > This MultiForm class should do this: > > - validate/clean all sub forms on clean(). Not just until > the first one fails, since the user should see all errors. > - Simple dependency: Example: FormB should be cleaned only if FormA > cleans successfully. (Since FormB requires data from FormA).
That part right there is one of the reasons a general class like this is probably not very easy. There are such a wide range of possibilities for that step ("this form only if two of the other three forms, but not all three have been completed"?). At some point, it's as complicated as Python is. However, constructing a custom class for your requirements wouldn't be too hard, I agree. You can probably subclass Formset and you'd only need to override the _construct_form() method to make things display and have the data populated: so that it doesn't use self.form each time around the but, rather, the right form class for that index. Similarly, you'd have to override full_clean() to both incorporate your "if-then" logic and use the right form class for each "i" value, rather than self.form, again. Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---