I also made this that is not pretty clean actually...

See this post :
http://groups.google.com/group/web2py/browse_frm/thread/50af0d67554c94d9/fffbdff01ac804d2?tvc=1#fffbdff01ac804d2

Richard

On Fri, Jan 21, 2011 at 4:05 PM, Richard Vézina <[email protected]
> wrote:

> There is a jQuery recipe about that look at the recipe section of the book.
>
> Richard
>
>
> On Fri, Jan 21, 2011 at 3:48 PM, Lennon <[email protected]> wrote:
>
>> I solved my problem.  Since the form.vars were passing through to the
>> controller, I just simply did my own manual insert:
>>
>> def test_add_user():
>>
>>    form = SQLFORM(db['user'])
>>     form.append(SQLFORM(db['address']))
>>
>>    #submit data
>>    if form.accepts(request.vars):
>>
>>        #check whether the form had errors
>>        if form.errors:
>>            response.flash = 'Form has errors'
>>            return dict(form=form)
>>        else:
>>
>> db.address.insert(user_id=form.vars.id,address=form.vars.address)
>>             session.flash = "User Added"
>>            redirect(URL('admin', 'test_add_user'))
>>
>>    #return the view
>>    return dict(form=form)
>>
>> Now all I have to do is remove the first submit button.
>>
>> On Jan 21, 2:30 pm, Lennon <[email protected]> wrote:
>> > I have two reasons for not wanting to use SQLFORM factory.  First, I
>> > can't figure out or find how to use SQLFORM factory as an update/
>> > delete form when combining multiple table (although I'd love to see
>> > how if it can be done).  Second, I will be wanting to do some really
>> > complicated forms in the future and would like to understand how to
>> > combine SQLforms.
>> >
>> > With the insert form code listed below, I've been able to combine the
>> > two forms on one page.  They both render (with two submit buttons) and
>> > the form validation works for both of them regardless of which submit
>> > button I hit (which made me think I had successfully combined them).
>> >
>> > But when the form accepts the data, it only does an insert on the
>> > original form and doesn't work on the appended form.
>> >
>> > When I run in debug mode I see that FORM.vars correctly has captured
>> > all of the values for both forms.  But FORM.table and FORM.fields both
>> > only have the values for the first SQLFORM.
>> >
>> > Thanks for any help you can give me.
>> >
>> > def test_add_user():
>> >
>> >     form = SQLFORM(db['user'])
>> >     form.insert(len(form),SQLFORM(db['address']))
>> >
>> >     #submit data
>> >     if form.accepts(request.vars):
>> >
>> >         #check whether the form had errors
>> >         if form.errors:
>> >             response.flash = 'Form has errors'
>> >             return dict(form=form)
>> >         else:
>> >
>> >             session.flash = "User Added"
>> >             redirect(URL('admin', 'test_add_user'))
>> >
>> >     #return the view
>> >     return dict(form=form)
>>
>
>

Reply via email to