How about something like,  

myform[0].insert(-1, TAG.BUTTON(T('Cancel')),_onclick=
'ajax("%s",[],":eval");' % URL(
        c='my_controller', f='cancel_update')
    )

If you want the cancel button to appear in the same table row as the submit 
button, you may need something like 

myform[0][1]...


On Monday, June 25, 2012 6:13:31 AM UTC-4, weheh wrote:
>
> My controller has a componentized form with an added Cancel button 
> like this (this is an excerpt, so sorry for any typos):
>
> def update( ):
>
>   myform = SQLFORM.factory(
>     Field('text_in','text',requires=IS_NOT_EMPTY()),
>     buttons=[INPUT(_type='submit',_value=T('Update'))],
>     _id='myform',
>     formstyle='divs'
>     )
>   form.element('input[type=submit]').parent.append(
>     TAG.BUTTON(T('Cancel')),_onclick='ajax("%s",[],":eval");' % URL(
>         c='my_controller', f='cancel_update')
>     )
>   if myform.process(formanem='myform').accepted:
>     ...do stuff...
>  return dict(myform=myform)
>
>
>
> The form submits 
> properly when the Update button is pressed. However, when the Cancel 
> button is pressed, not only does 
> the "cancel_update" callback get called, the form also gets submitted 
> erroneously. The question is, why does the "update" action get called and 
> its form get submitted at all when the Cancel button is pressed?
>
>

-- 



Reply via email to