Thanks, Anthony. I was under the impression that list:string is the 
convention if you want the field to render as a selector with SQLFORM(). 
You're right that it's possible to change the field from list:string to 
string and use IS_IN_SET() to maintain the field as a select element. 
However, I still cannot apply a list of validators after doing this. Having 
changed the field from list:string to string, when I apply the validators 
as such: Field(... requires=[IS_IN_SET(...)] ...), SQLFORM now renders the 
field as an input field rather than a drop-down menu/select element. 

On Tuesday, January 29, 2013 9:39:09 AM UTC-5, Anthony wrote:
>
> If you don't want to allow the user to select multiple options, then why 
> is the field type list:string rather than just string? If you make it just 
> a string type, then you will be able to apply a list of validators, as 
> below.
>
> Anthony
>
> On Tuesday, January 29, 2013 5:39:59 AM UTC-5, Lamps902 wrote:
>>
>> Thank you for the replies, guys! I think my abstract/trivial example may 
>> have obfuscated things a bit. I'm trying to use the IS_IN_SET() validator 
>> in combination with a custom validator (yet to be fully written) to make it 
>> so that all the elements of a dropdown menu/select are taken from a given 
>> set of options (a list of file formats), and for the selected option (file 
>> format), the custom validator will make sure the file is in that format. 
>> Something like this might be a better description than the initial post:
>>
>> Field('f_file_format, type='list:string', 
>>           
>> requires=[IS_IN_SET(theset=list_of_acceptable_options,zero=T('make a 
>> selection'), error_message=T(some_error_message)),
>>                       CUSTOM_VALIDATOR(request.vars.f_file_format, 
>> request.vars.file, error_message=T(some_error_message2))]
>>>
>>> )
>>
>> To clarify - I'm not seeking to let the user be able to select multiple 
>> options from the drop down list. Maybe it's better to implement the custom 
>> validator functionality I'm looking for in the controller, or can it be 
>> done in the model? 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