[web2py] Re: Flash message if before_insert fail

2016-02-19 Thread Anthony
> > db.poc.Name.requires = [IS_UPPER > (), CRYPT > (), > IS_NOT_IN_DB(db(db.poc.Birthday == > request.vars.Birthday), 'poc.Name')] > > > > I've tried but this doesn't work prop

[web2py] Re: Flash message if before_insert fail

2016-02-19 Thread Ivan Gazzola
Thx Anthony ! Il giorno giovedì 18 febbraio 2016 21:22:05 UTC+1, Anthony ha scritto: > > .. > > > db.poc.Name.requires = [IS_UPPER > (), CRYPT > (), > IS_NOT_IN_DB(db(db.po

[web2py] Re: Flash message if before_insert fail

2016-02-18 Thread Anthony
There are several problems. First, note that by default, form.process() sets the flash message after processing, and that happens *after* the database insert -- so the flash message you set in the _before_insert callback gets overwritten. Second, even though your callback prevents the insert, t

[web2py] Re: Flash message if before_insert fail

2016-02-18 Thread Ivan Gazzola
### Controller for poc form def insert_poc(): form=SQLFORM(db.poc) if form.process().accepted: response.flash = T('Record added') return dict(form=form) I've posted the full model, the function is colled in _before_insert: db.poc._before_insert.append(lambda dati: controlla_

[web2py] Re: Flash message if before_insert fail

2016-02-18 Thread Anthony
We need to see the full code, including the controller. In particular, you show a callback function, but you do not show where it is called. Anthony On Thursday, February 18, 2016 at 8:55:49 AM UTC-5, Ivan Gazzola wrote: > > > db.define_table('poc', > Field >

[web2py] Re: Flash message if before_insert fail

2016-02-18 Thread Ivan Gazzola
db.define_table('poc', Field ('Name',required=True), Field ('Birthday','date',widget=bsdatepicker_widget(),required=True), Field