[web2py] Re: validator for self-join
On Friday, May 6, 2011 8:56:12 AM UTC-7, pbreit wrote: I think this might be what you want: crud.settings.create_onvalidation.mytablename.append(lambda form:) http://web2py.com/book/default/chapter/07#Settings In the case of crud.update, it would be crud.settings.update_onvalidation. But crud.update(..., onvalidation=f) should work too.
[web2py] Re: validator for self-join
Thanks, that did it! On May 6, 9:56 am, pbreit pbreitenb...@gmail.com wrote: I think this might be what you want: crud.settings.create_onvalidation.mytablename.append(lambda form:) http://web2py.com/book/default/chapter/07#Settings
[web2py] Re: validator for self-join
I'm having trouble getting a custom validator to work with the crud form. Is the is the correct implementation? def f(form): #if form.vars.id == form.vars.myfield: form.errors.myfield = 'cannot be same as id' ... form = crud.update(db.mytable,myrecord,onvalidation=f) ... The form still works fine, but this doesn't ever display an error message even if i remove the if statement in the validator. Are custom validators done differently for CRUD and SQLFORM forms? Thanks! DR On May 5, 7:49 am, Massimo Di Pierro massimo.dipie...@gmail.com wrote: You will need your own. It may be easier to use the onvalidate attribute of the crud.update/crud.create forms On May 5, 8:29 am, Dave davidramsayreinh...@gmail.com wrote: I'm using aself joinon one of my data tables, and need a validator that makes sure a record isn't joined to itself. I also need to combine it with 2 other validators, IS_NULL_OR and IS_IN_DB. currently it looks like this: db.mytable.myfield.requires=IS_NULL_OR(IS_IN_DB(db,'mytable.id')) but i need to add one more check to make sure mytable.myfield does not equal mytable.id. Is there something like this available or do i need to create a custom validator? Thanks, DR
[web2py] Re: validator for self-join
I think this might be what you want: crud.settings.create_onvalidation.mytablename.append(lambda form:) http://web2py.com/book/default/chapter/07#Settings
[web2py] Re: validator for self-join
You will need your own. It may be easier to use the onvalidate attribute of the crud.update/crud.create forms On May 5, 8:29 am, Dave davidramsayreinh...@gmail.com wrote: I'm using a self join on one of my data tables, and need a validator that makes sure a record isn't joined to itself. I also need to combine it with 2 other validators, IS_NULL_OR and IS_IN_DB. currently it looks like this: db.mytable.myfield.requires=IS_NULL_OR(IS_IN_DB(db,'mytable.id')) but i need to add one more check to make sure mytable.myfield does not equal mytable.id. Is there something like this available or do i need to create a custom validator? Thanks, DR