When you add_button('cancel',....) you do not get a form.custom.cancel. 
Sorry.

On Monday, 1 October 2012 13:36:02 UTC-5, David Sorrentino wrote:
>
> Hi everybody,
>
> Sorry for re-opening this thread, but I'm trying without success to add a 
> cancel button to a CRUD form.
>
> Here my controller:
> def insertnews():
>     form = crud.create(db.news)
>     form.add_button("cancel",URL(r=request,f='index'))
>     return dict(form=form)
>
> Here my view:
> {{=form.custom.begin}}
> Body:
> <div>{{=form.custom.widget.body}}</div>
> {{=form.custom.submit}}
> {{=form.custom.cancel}}
> {{=form.custom.end}}
>
> Where am I wrong?
>
> Cheers,
> David
>
>
> On Thursday, 13 September 2012 23:49:01 UTC+2, Massimo Di Pierro wrote:
>>
>> +1
>>
>> On Thursday, 13 September 2012 12:17:17 UTC-5, Henrik Holm wrote:
>>>
>>> Has this "add_button" been added to one of the recent releases?  I'm 
>>> running 1.99.7 and I get 
>>>
>>>   *<type 'exceptions.AttributeError'> 'SQLFORM' object has no attribute 
>>> 'add_button'*
>>>
>>> Maybe it's time to upgrade :-)
>>>
>>> Thanks,
>>> Henrik
>>>
>>>
>>> On Tuesday, July 17, 2012 1:43:08 PM UTC-4, Massimo Di Pierro wrote:
>>>>
>>>> In trunk:
>>>>
>>>> form.add_button("Cancel",URL(r=request,f='new_contact'))
>>>>
>>>> On Tuesday, 17 July 2012 10:00:59 UTC-5, Mathias wrote:
>>>>>
>>>>> I found a good solution for me : 
>>>>>
>>>>> form[0][-1][1].append(TAG.INPUT(_value='Cancel',_type="button",_onclick="window.location='%s';"%URL(r=request,f='new_contact')))
>>>>>  
>>>>>
>>>>>
>>>>> Mathias 
>>>>>
>>>>>
>>>>> 2012/7/17 Mathias Van Daele <mathias...@gmail.com>: 
>>>>> > Thanks for your solution Richard ! 
>>>>> > 
>>>>> > I am still looking for a solution with a button component... 
>>>>> > 
>>>>> > Mathias 
>>>>> > 
>>>>> > 2012/7/17 Richard Vézina <ml.richa...@gmail.com>: 
>>>>> >> Maybe this could be enough?? 
>>>>> >> 
>>>>> >> {{=A(T('cancel'),_href="javascript:void(history.go(-1))")}} 
>>>>> >> 
>>>>> >> It will bring you back to the precedent page, in my use case, I 
>>>>> direct the 
>>>>> >> user on a crud.read page where the user can edit the record 
>>>>> (crud.update). 
>>>>> >> Then if don't want make change anymore there is a "cancel" 
>>>>> hyperlink that 
>>>>> >> bring back the user on the crud.read page. 
>>>>> >> 
>>>>> >> Richard 
>>>>> >> 
>>>>> >> 
>>>>> >> On Tue, Jul 17, 2012 at 8:13 AM, Mathias <mathias...@gmail.com> 
>>>>> wrote: 
>>>>> >>> 
>>>>> >>> Hello, 
>>>>> >>> 
>>>>> >>> I have added a CANCEL button to my SQLFORM. 
>>>>> >>> 
>>>>> >>> Form submission prevents the correct working of it. 
>>>>> >>> 
>>>>> >>> I have tried to avoid form submission with this code : 
>>>>> >>> 
>>>>> >>> 
>>>>> >>> def new_guest_contact(): 
>>>>> >>>    form = SQLFORM.factory(...) 
>>>>> >>> 
>>>>> >>> 
>>>>> >>> 
>>>>> form[0][-1][1].append(TAG.BUTTON('Cancel',_onclick='ajax("%s",[],":eval");return
>>>>>  
>>>>>
>>>>> >>> false' %URL(r=request,f='new_contact'))) 
>>>>> >>> 
>>>>> >>>    if form.process().accepted: 
>>>>> >>>         ... 
>>>>> >>>         redirect(URL(r=request,f='new_contact_part')) 
>>>>> >>>    elif form.errors: 
>>>>> >>>        response.flash = 'form has errors' 
>>>>> >>>    else: 
>>>>> >>>        response.flash = 'Create new guest' 
>>>>> >>> 
>>>>> >>>    return dict(form=form) 
>>>>> >>> 
>>>>> >>> 
>>>>> >>> If I click the cancel button now, nothing happens anymore. 
>>>>> >>> 
>>>>> >>> 
>>>>> >>> Any help is welcome. 
>>>>> >>> 
>>>>> >>> Thanks 
>>>>> >>> 
>>>>> >>> 
>>>>> >>> Mathias 
>>>>> >>> 
>>>>> >>> -- 
>>>>> >>> 
>>>>> >>> 
>>>>> >>> 
>>>>> >> 
>>>>> >> 
>>>>> >> -- 
>>>>> >> 
>>>>> >> 
>>>>> >> 
>>>>>
>>>>

-- 



Reply via email to