Actually, I fixed it another way. My problem was that I was using the same 
options as input for multiple SELECT()s. If I create new instances of 
OPTIONS() for each drop-down box, the state is correctly remembered.

Thanks,
Neil

On Saturday, May 12, 2012 12:22:13 AM UTC+1, Massimo Di Pierro wrote:
>
>
> You need 
>
> name = 'q%d' % (q_num)
> SELECT(....,value=request.vars.name or '0',...)
>
> Only SQLFORM remembers the state. primitive tags like SELECT, INPUT, 
> TEXTAREA that do not know state. you must pass state.
>
>
> On Friday, 11 May 2012 15:52:21 UTC-5, Neil wrote:
>>
>> I'm creating a form with drop down boxes like this:
>>
>> SELECT(*options, _name='q%d' % (q_num), requires=IS_IN_SET(['1', '2', 
>> '3', '4', '5'], error_message="Oops, looks like you missed this one.")
>>
>> When  options looks like this:
>>
>> options = ['0', '1', '2', '3', '4', '5']
>>
>> everything is fine. In particular, if there is a form validation error, 
>> the form remembers which options was selected for each item. 
>>
>> However, if  options looks like this:
>>
>> options = [OPTION('', _value='0'),
>>            OPTION('Never have the thought', _value='1'),
>>            OPTION('Rarely have the thought ', _value='2'),
>>            OPTION('Sometimes have the thought', _value='3'),
>>            OPTION('Often have the thought', _value='4'),
>>            OPTION('Always have the thought', _value='5')]
>>
>> The form initially displays correctly, but when there is a validation 
>> error, it forgets which option was previously selected. In particular, it 
>> always says selected="0".
>>
>> Is this a bug, or am I doing something wrong? Is there a workaround?
>>
>> Neil
>>
>>

Reply via email to