[web2py] Re: Is it possible to use IS_IN_SET() in combination with other validators to validate a list?
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.
[web2py] Re: Is it possible to use IS_IN_SET() in combination with other validators to validate a list?
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.
[web2py] Re: Is it possible to use IS_IN_SET() in combination with other validators to validate a list?
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.
[web2py] Re: Is it possible to use IS_IN_SET() in combination with other validators to validate a list?
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.
[web2py] Re: Is it possible to use IS_IN_SET() in combination with other validators to validate a list?
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.
[web2py] Re: Is it possible to use IS_IN_SET() in combination with other validators to validate a list?
I think you want requires=IS_LIST_OF(IS_IN_SET()) It should validate but you will not get dropdowns. On Monday, 28 January 2013 20:57:58 UTC-6, Lamps902 wrote: Hi, web2py users. In my model, I've got a field of type list:string which I'm trying to validate. The field is defined as follows: Field('f_field_name', type='list:string', requires=IS_IN_SET(theset=list_of_acceptable_options,zero=T(message), error_message=T(some_error_message))) This renders perfectly well as a select element/drop-down menu when the table that contains it is passed to SQLFORM(). However, if I pass a list of validators to requires, the list renders as an unordered list containing an input box and a javascript:void(0) reference. For instance, the following trivial example would render in the fashion described: Field('f_field_name', type='list:string', requires=[IS_IN_SET(theset=list_of_acceptable_options,zero=T(message), error_message=T(some_error_message)), IS_IN_SET(theset=list_of_acceptable_options,zero=T(message), error_message=T(some_error_message))] ) Any ideas as to what the issue could be? Any recommendations on how to use IS_IN_SET() in combination with another validator? Thanks! -- --- 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.
[web2py] Re: Is it possible to use IS_IN_SET() in combination with other validators to validate a list?
Are you saying you want to be able to apply the IS_IN_SET validator to each entry in the field? If so, you can do IS_IN_SET(..., multiple=True) or IS_IN_SET(..., multiple=(min, max)). See the IS_IN_SET documentation here: http://web2py.com/books/default/chapter/29/07#Validators Anthony On Monday, January 28, 2013 9:57:58 PM UTC-5, Lamps902 wrote: Hi, web2py users. In my model, I've got a field of type list:string which I'm trying to validate. The field is defined as follows: Field('f_field_name', type='list:string', requires=IS_IN_SET(theset=list_of_acceptable_options,zero=T(message), error_message=T(some_error_message))) This renders perfectly well as a select element/drop-down menu when the table that contains it is passed to SQLFORM(). However, if I pass a list of validators to requires, the list renders as an unordered list containing an input box and a javascript:void(0) reference. For instance, the following trivial example would render in the fashion described: Field('f_field_name', type='list:string', requires=[IS_IN_SET(theset=list_of_acceptable_options,zero=T(message), error_message=T(some_error_message)), IS_IN_SET(theset=list_of_acceptable_options,zero=T(message), error_message=T(some_error_message))] ) Any ideas as to what the issue could be? Any recommendations on how to use IS_IN_SET() in combination with another validator? Thanks! -- --- 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.