Jon Loyens wrote:
Hi all,I have a sight where I need to generate forms that are made up of two or three other forms. For example I have New User sign up form that accepts user information (user name, name, password), a shipping and a billing address (with the same usual field) and credit card info. Sometimes, I need a composite form with all of the above while sometimes I need a form with just a subset of the information. As an example, I'd like to define a series of forms like this:
<snip>
There is no reason that you couldn't include multiple forms in an HTML post operation. You just have to make sure that there won't end up beingIs there a way to do this sort of thing with the Forms API? I had hope for FormSets but that's a more dynamic thing that I need which is really a Composite form pattern.
duplicate fields across forms.You'd have your view figure out just which 3 you need, and then call the appropriate template. You'd end up having something like:
<form method="post">
{{ CreditCardForm.as_ul }}
{{ AddressForm.as_ul }}
{{ NewUserForm.as_ul }}
<input type="submit" />
</form>
Your view would then create an instance of all three forms with the
request.POST data. When forms get passed a value they don't need, they
discard it. Simple as pie.
Hopefully this is helpful! Jeff Anderson
signature.asc
Description: OpenPGP digital signature

