I asked this in a previous question I posted but felt it may not be picked
up quick enough, I dont mean to be repetitive i just need help on it
immediately!
After a form has failed to save because that information already exists in
the database I wanna try & alter the value that determines a day where the
info is saved in the db for the form to be saved in a different day that
does not contain similar form details currently attempting to be saved and
this should be done automatically without the engaging the user, I then
tried this below but I feel I didnt write it correctly;
*CODE:*
def my_validator(form):
control=['1', '2', '3', '4' ,'5']
form.vars.controller = random.choice(control)
if db((db.lecture.id == form.vars.id) & (d.controller==form.vars.
controller) & (db.lecture.lecture_time == form.vars.lecture_time)).count() >
0:
if int(form.vars.controller) < int(control[4]):
int(form.vars.controller) +1
response.flash=T('Saved in',' ', int(form.vars.controller) +1)
if int(form.vars.controller) > int(control[4]):
int(form.vars.controller) -1
repsonse.flash=T('Saved in',' ', int(form.vars.controller) -1)
else:
form.errors.lecturer=SPAN("Record already exists in the whole
database", _style="font-weight: bold;")
def index():
details=db(db.lecture).select()
form=SQLFORM(db.lecture)
if form.process(onvalidation=my_validator).accepted:
response.flash=T('Submitted')
return locals()
This is the concept thats in my head, where can I fix it?
Regards;
Mostwanted
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/web2py/312869e5-8e50-4398-9949-ef268bad9829o%40googlegroups.com.