On Tue, Dec 22, 2009 at 6:59 PM, Mark <[email protected]> wrote:
> Hi guys,
>
> I have a class form that enables users to enter information about a
> class (ie. class id, class type, course name, registration
> deadline...) and also allows users to dynamically add sessions.
> Sessions consists of start/end datetime, location and description.  I
> want them to add multiple sessions at a go before submitting the form
> for processing and then saving the information to my database.
>
> If I have multiple session sub-forms in my class form, won't all of
> them have the same name?  Can I use name=session_description[]?  How
> would I capture the data in my controller?
>
> session_description[] = request.params.get('session_description')
> for session in session_description:
>  Save to DB

FormEncode has support for this but I've never been able to figure it
out exactly.  You'd put all the fields on one form, and name them
something like 'session-1.description;.  The NestedVariables
pre-validator will unpack them into a list of dicts, so you'd use
something like ForEach('session'), with a schema validator for the
session.  But I've never quite figured it out so you'll have to read
the FormEncode manual and the source.  You can either put a fixed
number of rows on the form, or have a Javascript button to add a row.

-- 
Mike Orr <[email protected]>

--

You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.


Reply via email to