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 <[email protected]>
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 <[email protected]> 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
>
>