IS_EMPTY_OR(IS_IN_DB(...))

See http://web2py.com/book/default/chapter/07#Validators.

Anthony

On Friday, October 21, 2011 3:35:06 AM UTC-4, Calycé wrote:
>
> Hi all, 
>
> I have created a table with a self reference as described below: 
> db.define_table('category', 
>     Field('parent_category', 'reference category'), 
>     Field('name', 'string', length=40, required=True), 
>     Field('description', 'text', required=True), 
>     Field('small_image', 'upload')) 
>
> Now I'd like to have an "optional requires" clause. For example, if I 
> add the following clause "store.category.parent_category.requires = 0 
> or IS_IN_DB(db, db.category.id, '%(name)s')" I have a nice combo 
> whenever I use the appdadmin to insert rows BUT I have to select 
> something from the combo. In my case, the parent_category field should 
> be optional. In extenso, categories without parent_category would be 
> root categories so selecting a parent_category is optional. 
>
> Is there a way to present a combo as does the "requires" but without 
> enforcing the field ? Do I have to create a specific form for that ? 
>

Reply via email to