Yes, I was saying if it doesn't work, it should probably be changed so it 
does.

On Friday, September 30, 2011 2:25:18 PM UTC-4, jkral wrote:
>
> Unless I am implementing it wrong, and I very well maybe, 
> IS_NOT_EMPTY() does not work: 
>
> db.info.environment.requires = [ IS_NOT_EMPTY(), 
> IS_IN_SET(ENVIRONMENTS, multiple=True, error_message='Please select 
> appropriate environment(s).') ] 
> or 
> db.info.environment.requires = IS_NOT_EMPTY(IS_IN_SET(ENVIRONMENTS, 
> multiple=True, error_message='Please select appropriate 
> environment(s).')) 
>
>
>
>
> On Sep 30, 12:33 pm, Anthony <abas...@gmail.com> wrote: 
> > It seems like IS_NOT_EMPTY() should be made to work in this case (i.e., 
> > validation should fail if no items were selected). 
> > 
> > Anthony 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > On Friday, September 30, 2011 1:23:35 PM UTC-4, jkral wrote: 
> > 
> > > Thanks DenesL,  and yes I knew that multiple=True accepted 0 or more, 
> > > I just wasn't sure if there was another validator that I could use in 
> > > conjunction with IS_IN_SET(multiple=True) 
> > > So then I have to create my own check, there's not "quick fix"? 
> > 
> > > Thanks 
> > 
> > > Jon 
> > > ;) 
> > 
> > > On Sep 30, 8:09 am, DenesL <den...@yahoo.ca> wrote: 
> > > > Hi jkral, 
> > 
> > > >http://web2py.com/book/default/chapter/07#Validators 
> > > > under IS_IN_SET and Tagging 
> > > > "Note that when multiple=True, IS_IN_SET will accept zero or more 
> > > > values, i.e. it will accept the field when nothing has been 
> selected." 
> > 
> > > > so you have to check for an empty selection and error out. 
> > 
> > > > Example: 
> > 
> > > > def multiempty(): 
> > 
> > > >   colors = ( (0, 'red'), (1, 'green'), (2, 'blue') ) 
> > 
> > > >   def musthavecolor(form): 
> > > >     if not form.vars.color: 
> > > >       form.errors.color = 'can not be empty' 
> > 
> > > >   form = SQLFORM.factory( 
> > > >     Field('color', 
> > > >            widget=SQLFORM.widgets.checkboxes.widget, 
> > > >            requires = IS_IN_SET(colors, multiple=True) ) 
> > > >   ) 
> > 
> > > >   return dict(form = form.process( 
> > > >     onvalidation = musthavecolor, 
> > > >     message_onsuccess = 'ok', 
> > > >     message_onfailure = 'not ok')) 
> > 
> > > > On Sep 29, 2:11 pm, jkral <jk...@gogoair.com> wrote: 
> > 
> > > > > I am having some troubles getting my form to error when no items 
> are 
> > > > > selected in the environment field. 
> > > > > Could someone please shed some insight?  and I apologize in advance 
> if 
> > > > > this request is redundant. 
> > 
> > > > > from <specific module> import ENVIRONMENTS 
> > > > > ##ENVIRONMENTS is a tuple 
> > 
> > > > > db.define_table('info', 
> > > > >   Field('info_number', 'integer', label='Info Number'), 
> > > > >   Field('description', 'text'), 
> > > > >   Field('environment', widget=SQLFORM.widgets.checkboxes.widget), 
> > > > >   Field('notice')) 
> > 
> > > > > db.info.environment.requires = IS_IN_SET(ENVIRONMENTS, 
> multiple=True, 
> > > > > error_message='Please select appropriate environment(s).') 
> > 
> > > > > The other fields error (if empty) based on their respective 
> validators 
> > > > > this is what I want for the environment field, but it returns an 
> empty 
> > > > > [] 
> > 
> > > > > Also please note that I did receive an error_message before I added 
>
> > > > > multiple=True. 
> > 
> > > > > I have tried: 
> > 
> > > > > db.info.environment.requires = [IS_NOT_EMPTY(), 
> > > > > IS_IN_SET(ENVIRONMENTS, multiple=True, error_message='Please select 
>
> > > > > appropriate environment(s).')] 
> > 
> > > > > but no avail

Reply via email to