Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » Need some ideas for how to implement a two-part form [RSS Feed]

#1 Jan. 26, 2011 22:00:08

j.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Need some ideas for how to implement a two-part form


I'm working on a project that requires a RSVP form for an event.

The first step of the form would ask first & last name, e-mail,
attending (yes/no/unsure), and total number of guests attending.
Currently I have this form correctly working and submitting to the
database.

The second step of the form would interact with a second table which
would be the guest list and it would only contain the first & last
name of each guest along with who registered them. It would give
enough forms to add the names of the guests from that party attending
(based on number submitted in the first step and only if the rsvp
response was Yes). The registered by column should be filled
automatically and be hidden on the client-side.
So far I have this working for just one name entry (pulls from POST
data).

So the real question is, what is the best way to go about adding a
secondary form which automatically provides enough name fields based
on the field filled in the first form? Also it should add the
registering guest's name to the first set of fields for convenience.

I'd be open to adding some sort of js/jquery/ajax/whatever to have the
form be all one page and dynamically add the number of name fields but
still save those to the second database table.

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 Jan. 26, 2011 22:33:31

Shawn M.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Need some ideas for how to implement a two-part form


Try using formsets or model formsets.http://docs.djangoproject.com/en/dev/topics/forms/formsets/As for remembering some information about the form without displaying it, in
your case it sounds like the guest form could have a foreign key to the party
they're attending. You could exclude that key from the form that is displayed
to the user (using 'exclude' in the class meta). You can access the guest
instance from within the guest form by using self.instance, so the party can be
accessed via self.instance.party in your custom clean() and save() code.

Shawn

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

  • Root
  • » Django
  • » Need some ideas for how to implement a two-part form [RSS Feed]

Board footer

Moderator control

Enjoy the 16th of August
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support