Looks like a bug in IS_EMPTY_OR -- it ignores the zero argument to IS_IN_DB 
and instead forces the zero choice to be ''. Please file a Google Code 
issue.

For now, here's a workaround:

form.element('option[value=]').append(T('<empty>'))

Anthony

On Tuesday, July 2, 2013 7:22:50 AM UTC-4, Loïc wrote:
>
> Hello all
>
> I a controller, I define a contact form like this : 
>
> form=SQLFORM.factory(
>         Field('your_name',requires=IS_NOT_EMPTY(), label=T('Your name')),
>         Field('your_email',requires=IS_EMAIL(), label=T('Your email')),
>         Field('subject',requires=IS_NOT_EMPTY(), label=T('Subject')),
>         Field('person', requires=IS_EMPTY_OR(IS_IN_DB(db, db.contact.id, 
> '%(name)s', zero=T('<Empty>'))), label=T('Contact')),
>         Field('message', 'text',requires=IS_NOT_EMPTY(), label=T('Message'
> ))
>         )
>
>
> When the contact form is displayed, I got a dropdown list for "person" 
> value, but the default value is blank instead of '<Empty>'
> How could I get a default value when the dropdown list is empty?
>
> Thank you
>

-- 

--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to