The other way is to do something in onaccept:
def do_stuff(bla):
session.flash = "I've just changed the flash message"
def set_flash(form):
if session.flash:
response.flash = session.flash
orm = crud.create(db.some_table, next=URL()+'?id=[id]', onvalidation=
do_stuff, onaccept=set_flash)
Anthony
On Tuesday, June 4, 2013 4:57:42 AM UTC-4, guruyaya wrote:
>
> No, the outcome changes as a result of the onvalidatoion / onaccept
> operation. Is there any other way, or I'll just use SQLFORM and forget
> about it?
>
> On Monday, June 3, 2013 6:36:29 PM UTC+3, Anthony wrote:
>>
>> Is it possible to determine the message before calling crud.create()? If
>> so, you can either set crud.messages.record_created or use the "message"
>> argument to crud.create(). Otherwise, you'll have to use an onaccept
>> function instead of onvalidation to change the message -- and you should
>> set response.flash rather than session.flash (crud.create() will
>> automatically copy the message to session.flash in case of a redirect).
>>
>> Anthony
>>
>> On Monday, June 3, 2013 5:25:08 AM UTC-4, guruyaya wrote:
>>>
>>> Say I'm using this crud function
>>> form = crud.create(db.some_table, next=URL()+'?id=[id]',
>>> onvalidation=do_stuff)
>>>
>>> def do_stuff(bla):
>>> session.flash = "I've just changed the flash message"
>>>
>>> Well, I've tried this one. It doesn't change the flash message (I get
>>> the usual "Record created"), wether I'm using onaccept or onvalidation.
>>> Is there any way I can change the flash message, that I miss?
>>>
>>> Thanks in advance
>>> Yair
>>>
>>
--
---
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/groups/opt_out.