I think you misunderstand the confirmation form functionality. FORM.confirm 
is a static method of the FORM class, so calling it on an existing form 
object will do nothing to that form -- it will instead return a completely 
new form (so, you might as well just call FORM.confirm rather than 
form.confirm on your existing form). Because it creates a whole new form, 
you must explicitly show the new form in your view. However, it looks like 
you don't really want this -- instead, you want a dialog to pop up when the 
user attempts to submit an existing SQLFORM. web2py does not include 
built-in functionality to do what you want -- you will have to handle that 
via Javascript on the client.

Another option would simply be to include a boolean field in the main form 
(e.g., checkbox or switch widget) asking if the data should be added to the 
other table. Then check for that flag in the controller and proceed 
accordingly. See 
http://web2py.com/books/default/chapter/29/07/forms-and-validators#Adding-extra-form-elements-to-SQLFORM.

Anthony

On Friday, March 4, 2016 at 4:20:20 AM UTC-5, Viator wrote:
>
>
>
> Am Donnerstag, 3. März 2016 16:01:53 UTC+1 schrieb Anthony:
>>
>> Have you put the form in your view somewhere via {{=form}}?
>>
>> Note, it doesn't generate a pop-up, just a standard form.
>>
>> Anthony
>>
>
> Hi Anthony!
>
> Thank you for your help.
>
> I'm afraid I don't understand you completly. I have a form, which is in 
> the view and which is displayd. I can enter values and the values are 
> stored in the db. So far it works fine.
> Additionally I want to aks the user if he wants to add some of the added 
> data to another table when the user clicks on "save".
> As far as I understood, this can be done using form.confirm which will pop 
> up a dialog.
>
> The code (as far as I understand it should work):
>
> def client_create():
>     db.ck_client.default = request.args(0)
>     form = SQLFORM(db.ck_client, keepvalues=True)
>     form.add_button('Cancel', URL('clients'))
>
>     if form.process().accepted:
>
>          form_confirm = form.confirm("Do you want to add this to other 
> table?", hidden=False)        # FORM.confirm(.... does not work either
>         # neither does it if I remove the hidden=False parameter
>
>         if form_confirm.accepted:
>             # add to another table
>
>
>             db.my_table.insert(enabled='True',
>                               direction='INCOMING',
>                               description=form.vars.description,
>                               client_id=form.vars.id,
>                               )
>
>         response.flash = 'form accepted'
>         redirect(URL('clients'))
>     elif form.errors:
>         response.flash = 'form has errors'
>     return locals()
>
>
> I don't know if I do not understand how form.confirm should work, if I 
> miss something or if this is a bug and, as mentioned, I could not find any 
> working example for this. Only massimos hint to:
>
> form = FORM.confirm('Are you sure?')
> if form.accepted: do_what_needs_to_be_done()
>
> which doesn't help me any further.
>
>
>
> Thank you for helping me, Thorsten
>  
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to