confirm on form submit

34 views
Skip to first unread message

Vlad

unread,
Dec 4, 2019, 12:56:09 AM12/4/19
to web2py-users
The view has the following link: 

{{=A('Refunded', callback=URL('refund', target='REFUND')}}
<div id="REFUND"></div>

The function 'refund' returns the form, and the idea is that this form can change from the initial form to a confirmation form: 

def refund():
   
    form=FORM('Refund:',
              INPUT(_name='amount', requires=IS_NOT_EMPTY()),
              INPUT(_type='submit'),
              _name='form_one')
    if form.accepts(request, session, formname='form_one'):
       form2 = FORM.confirm('Are you sure to refund $%s?' % (form.vars.amount))
       if form2.accepted:
          return '%s refunded' % (form.vars.amount)
       return form2
   
    return form

On form submit form2 opens up, but on submit form2 the initial form is back (instead of displaying '%s refunded' ). 

What would be the way to implement the intended functionality correctly? 

I simply need to display form first, and on submit display form2-confirmation, and on form2 submit to do some operation and display the result. 


Massimiliano

unread,
Dec 4, 2019, 1:28:28 AM12/4/19
to web...@googlegroups.com
Don't use the callback, instead submit the form passing the refound param. If it exists, return form 2.

--
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 web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/6895f84c-43ca-4452-9a79-faa3c17f2837%40googlegroups.com.


--
Massimiliano
Reply all
Reply to author
Forward
0 new messages