Works like a charm, thanks Massimo!

On Thu, Dec 12, 2013 at 3:25 PM, Massimo Di Pierro <
[email protected]> wrote:

> This would work. Yet it will not preserve the order in the list of
> options. To preserve the order replace
>
>  options = {'Apple':T('Apple'),'Banana':T('Banana'),'Cherry':T('Cherry')}
>
> with
>
>  options = (('Apple',T('Apple')), ('Banana',T('Banana')), ('Cherry',T(
> 'Cherry')))
>
>
> On Thursday, 12 December 2013 08:12:50 UTC-6, Ruud Schroen wrote:
>
>> Would this work?
>>
>> On Saturday, November 16, 2013 1:21:07 PM UTC+1, Paolo Caruccio wrote:
>>>
>>> The IS_IN_SET validator allows to list the options as a dictionary (
>>> http://web2py.com/books/default/chapter/29/07/forms-
>>> and-validators?search=IS_IN_SET)
>>>
>>> Therefore, for an example, you could do:
>>>
>>>  def index():
>>>    options = {'Apple':T('Apple'),'Banana':T('Banana'),'Cherry':T(
>>> 'Cherry')}
>>>    form=SQLFORM.factory(Field('fruit',requires=IS_IN_SET(options,zero=
>>> None)))
>>>    if form.accepts(request, session):
>>>        selected = options[form.vars.fruit]
>>>        saved = form.vars.fruit
>>>        response.flash='selected %s in drop down list, saved %s in db' %(
>>> selected, saved)
>>>    return dict(form=form)
>>>
>>>
>>
>> On Thu, Dec 12, 2013 at 2:38 PM, 黄祥 <[email protected]> wrote:
>>
>>> yes, you are right, i'm understand right now, thanks for correct my
>>> mistake.
>>>
>>> please also take a look at this discussion
>>>
>>> ref:
>>> https://groups.google.com/forum/#!topic/web2py/WbF7GlZ9uKc
>>>
>>> thanks and best regards,
>>> stifan
>>>
>>> --
>>> 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 a topic in the
>>> Google Groups "web2py-users" group.
>>> To unsubscribe from this topic, visit https://groups.google.com/d/
>>> topic/web2py/Q51pSDExMcE/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> [email protected].
>>>
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>  --
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/Q51pSDExMcE/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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