Thanks Anthony, it works! I have prepared this wrapper, useful for newbies
like me:
def form_prepare_opts(mydict):
return [OPTION(mydict[code], _value=code) for code in mydict]
And then, in the controller function:
countries_opts = form_prepare_opts(countries)
Which can be used to initialize the select:
TR(T("Country: *"), SELECT(countries_opts, _name="country",
requires=IS_IN_SET(countries)))
On Wednesday, August 29, 2012 4:43:25 PM UTC+2, Anthony wrote:
>
> SELECT([OPTION(countries[code], _value=code) for code in countries])
>
> Anthony
>
> On Wednesday, August 29, 2012 3:15:13 AM UTC-4, Daniel Gonzalez wrote:
>>
>> Hi,
>>
>> I have the following map:
>>
>> countries = {
>> 'DE': T('Germany'),
>> 'ES': T('Spain'),
>> 'IT': T('Italy'),
>> 'US': T('United States')
>> }
>>
>> Which I am using to create a form, with the following entry:
>>
>> TR(T("Country:"), SELECT(*countries, _name="country",
>> requires
>> =IS_IN_SET(countries)))
>>
>> My problem is that the form is not showing the real names ('Germany',
>> 'Spain', ...), but the codes ('DE', 'ES', ...). How can I make sure that
>> the real names are shown, *but* the code is returned when selected?
>>
>> Thanks
>> Daniel
>>
>
--