close

db.dog.owner.requires = [IS_NULL_OR(IS_IN_DB(db, 'person.id', '))]

On Feb 15, 10:53 pm, reyelts <reye...@gmail.com> wrote:
> I have a field that I want validated in an SQLFORM, but I don't want a
> dropbox. The book directs us to use brackets as follows:
>
>    If you want the field validated, but you do not want a dropbox, you
> must put the validator in a list.
>
>    db.dog.owner.requires = [IS_IN_DB(db, 'person.id', ')]
>
> I also want the field to be able to be null. The book directs us to
> use IS_NULL_OR as follows:
>
>    Sometimes you need to allow empty values on a field along with
> other requirements. For
>    example a field may be a date but it can also be empty. The
> IS_NULL_OR validator
>    allows this:
>
>    requires = IS_NULL_OR(IS_DATE())
>
> So, I attempted to combine the two:
>
>    db.dog.owner.requires = IS_NULL_OR([IS_IN_DB(db, 'person.id', ')])
>
> But, this results in an error (traceback info below). If I don't
> include the brackets, the form works fine (except it populates a
> dropbox as one would expect).
>
> Is this an error on my part, a restriction that needs to be
> documented, or an error in web2py?
>
> ===========================================
>
> S'Traceback (most recent call last):\n  File "gluon/restricted.py",
> line 173, in restricted\n  File "w:\\web2py_win\\applications\
> \canyonezt/controllers/default.py", line 166, in <module>\n  File
> "gluon/globals.py", line 96, in <lambda>\n  File "gluon/tools.py",
> line 1851, in f\n  File "w:\\web2py_win\\applications\\canyonezt/
> controllers/default.py", line 127, in profile\n  File "gluon/
> sqlhtml.py", line 839, in accepts\n  File "gluon/html.py", line 1311,
> in accepts\n  File "gluon/html.py", line 452, in _traverse\n  File
> "gluon/html.py", line 452, in _traverse\n  File "gluon/html.py", line
> 452, in _traverse\n  File "gluon/html.py", line 452, in _traverse\n
> File "gluon/html.py", line 459, in _traverse\n  File "gluon/html.py",
> line 1118, in _validate\n  File "gluon/validators.py", line 2210, in
> __call__\nTypeError: \'list\' object is not callable\n'

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.

Reply via email to