def my_validator(form):
details=db(db.lecture).select()
for d in details:
if form.vars.lecturer==d.lecturer.id and form.vars.lecture_time==d.lecture_time:
form.errors.lecturer=SPAN("There is a conflict with these values!", _style="font-weight: bold;")
form.errors.lecture_time=SPAN("There is a conflict with these values!", _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()
Hey Dave, thanks for replying,This below is what I tried & it seems to be working, idont know if the best solution but please help e where u think I could improve it:
def my_validator(form):
details=db(db.lecture).select()
for d in details:
if form.vars.lecturer==d.lecturer.id and form.vars.lecture_time==d.lecture_time:
form.errors.lecturer=SPAN("There is a conflict with these values!", _style="font-weight: bold;")
form.errors.lecture_time=SPAN("There is a conflict with these values!", _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()
def my_validator(form):
)
.count() >0:
form.errors.lecturer=SPAN("Record already exists", _style="font-weight: bold;")
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;")