Take a look at this: http://web2py.com/books/default/chapter/29/7#FORM
Specifically this example:
db.define_table('numbers',
Field('a', 'integer'),
Field('b', 'integer'),
Field('c', 'integer', readable=False, writable=False))
def my_form_processing(form):
c = form.vars.a * form.vars.b
if c < 0:
form.errors.b = 'a*b cannot be negative'
else:
form.vars.c = c
def insert_numbers():
form = SQLFORM(db.numbers)
if form.process(onvalidation=my_form_processing).accepted:
session.flash = 'record inserted'
redirect(URL())
return dict(form=form)
What you want to do is write your own validator, so that it will check if
the data is already in the database, and if so, modify the form such that
there is an extra checkbox 'i am sure that i know that this is already
there'.
Perhaps that will help?
On Tuesday, March 27, 2012 1:14:02 PM UTC-7, Larry Wapnitsky wrote:
>
> Last question of the day, I promise...
>
> So, I have data that exists in my database. If a user enters a value
> that already exists, I want to prompt them with an "are you sure?" type
> question before the function that adds/updates the data continues.
>
> How do I interrupt my current function to do so without leaving the page
> and losing data?
>
> Thanks,
> Larry
>
>