Yep, that took care of it. Thanks a lot!

-Lamps

On Tuesday, January 29, 2013 10:56:41 PM UTC-5, Anthony wrote:
>
> The IS_IN_DB validator takes an _and argument to get around this problem, 
> but there is no _and argument for IS_IN_SET(). Instead, you can explicitly 
> set the widget for the field:
>
> Field('f_file_format,
>     requires=[IS_IN_SET(list_of_acceptable_options), 
> CUSTOM_VALIDATOR(...)],
>     widget=SQLFORM.widgets.options.widget)
>
> As long as the IS_IN_SET validator is the first one in the list, the 
> widget will build its options using the IS_IN_SET options.
>
> For more on widgets, see 
> http://web2py.com/books/default/chapter/29/07#Widgets.
>
> Anthony
>
> On Tuesday, January 29, 2013 1:36:24 PM UTC-5, Lamps902 wrote:
>>
>> 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