I would like to generate a form2  based on input from form1.

#Normal processing in test2 works fine. so all ok if both forms are made on 
init of page.

def test2():
    action = request.args(0)
    
    form1 = FORM(
                INPUT(_id = 'foo', _name = 'foo'),
                INPUT(_type='submit', _value="submit")
            )

    form2 = FORM(INPUT(_id = '0', _name = '0'),
                                INPUT(_id = '1', _name = '1'),
                                INPUT(_id = '2', _name = '2'),
                                INPUT(_type='submit', _value="submit"))
           
    f1_vars = False
    f2_vars = False
    if form1.process(formname="form_one").accepted:
        f1_vars = form1.vars
            
    if form2.accepts(request.vars, session, formname="form_two"):
        f2_vars = form2.vars

    return {'form1':form1, 'form2':form2, 'f1v':f1_vars, 'f2v':f2_vars}


## This section is not working - why ??
# form is processing, but not accepted on submit. 


def test():
    
    form1 = FORM(
                INPUT(_id = 'foo', _name = 'foo'),
                INPUT(_type='submit', _value="submit")
            )
    
    form1_vars = False
    form2_vars = False
    form2 = False
    e = {}
    if form1.process(formname="form_one").accepted:
        form2 = FORM(INPUT(_id = '0', _name = '0'),
                            INPUT(_id = '1', _name = '1'),
                            INPUT(_id = '2', _name = '2'),
                            INPUT(_type='submit', _value="submit"))
    
        if form2.process(formname="form_two"):
            e = {'p':'process ok'}
        elif form2.accepted:
            e =  form2.vars
        else:
            e = {'s':'something else'}
        return {'form2':form2, 'e':e}   
    return locals()

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to