Hi,
I have a search bar with 2 columns, group and address. 

    form = SQLFORM.factory(Field('ugroup', requires=IS_IN_DB(db, 
customers.gid', '%(group)s'), label='User group'),
                            Field('address', label='address'), 
                            formstyle="divs", submit_button="Search", 
keepvalues=True
                            )

The search page renders fine. But the search submission always forces to 
choose the ugroup from the drop-down, else i get the "value not in 
database" error.
I want the search to choose either ugroup or address, optionally both for 
narrow results.

How can i make 
1. IS_IN_DB validation optional or 

2. Override the IS_IN_DB validation with my custom validation something 
like this

    def check_search(form):
        if (not form.vars.ugroup) and (not form.vars.address):
            form.errors.ugroup= 'Need input on user group or address'

   if form.process(onvalidation=check_search).accepted:
      ....perform next steps
 

I don't like to make the ugroup, a text box, when drop-down is better from 
usability perspective.

Thanks,
Yogesh

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to