The problem is that if you use CRUD you should not call process. There are two more issues: 1) requires_IS_NOT_IN_DB() does already what myvalidation is supposed to do and better (it allows to edit the file itself which contains the value of name, while myvalidation cannot be used in editing because would generate an error) 2) you should use SQLFORM instead of crud.
Try this: table('stations', Field('name')) db.stations.name.requires = IS_NOT_IN_DB(db, 'stations.name',error_message="station name already exists!") db.stations.name.writable = False form = SQLFORM(db.stations).process(next=URL('index')) if form.vars.errors.name: response.flash = T("station name already exists!") On Thursday, 25 July 2013 15:37:06 UTC-5, Antonis Konstantinos Tzorvas wrote: > > hi, > > i'm having this model: > table('stations', Field('name')) > db.stations.name.requires = IS_NOT_IN_DB(db, 'stations.name') > > and i am creating a crud.create with this: > > if request.vars: > db.stations.name.default = request.get_vars['_name'] > db.stations.name.writable = False > form = crud.create(db.stations).process(next=URL('index'), > onvalidation=myvalidation) > > def myvalidation(form): > station = db(db.stations.name==form.vars.name) > if station: > form.errors.name = "station name already exists!" > response.flash = T("station name already exists!") #gets ignored > > the thing is that i cannot show the form.errors.name message under the > field or send a specialized response.flash message, any idea on how to add > this behavior? > thanks! -- --- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.