Does the error occur on the 'empty' option of the select?. You are introducing a 0 index value which is invalid in the db
On Jan 15, 7:47 am, Miguel Lopes <[email protected]> wrote: > 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]. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.

