db.task.contact_id.requires=IS_NULL_OR(IS_IN_DB(db,'contact.id','%(name)s'))
do what you want 2010/1/15 Miguel Lopes <[email protected]> > I have a select field on a form. It might be empty or take one related > value. > > I the model: > db.task.contact_id.requires=IS_IN_DB(db,'contact.id','%(name)s') > db.task.contact_id.requires.zero='' > > In a custom form: > {{keys, values=[''],[0] > keys.extend([contact.name for contact in contacts]) > values.extend([contact.id for contact in contacts]) > items=zip(values,keys)}} > {{=SELECT([OPTION(k,_value=v) for (v,k) in items], _name="contact_id")}} > > This results in a form.errors of 'value not in database' for the contact_id > field. > I'm sure this is very trivial. But I'm haven't found a way of solving this. > > Txs for the help, > Miguel > > -- > You received this message because you are subscribed to the Google Groups > "web2py-users" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<web2py%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/web2py?hl=en. > > -- Atenciosamente -- ========================= Alexandre Andrade Hipercenter.com--
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/web2py?hl=en.

