Discussion:
[FE-discuss] How to make sure at least one checkbox is checked?
Matthew Wilson
2008-09-07 15:12:01 UTC
Permalink
I've got a list of checkboxes, each with the same name and the value
attribute is an integer between 1 and 10.

Right now, I'm converting this to a list like this:

from formencode import validators
validators.ForEach(validators.Int(), convert_to_list=True)

I'd like to add another validator to make sure at least one checkbox is
checked, but I can't figure out how to do that.

Any suggestions?

Matt
--
Matthew Wilson
***@tplus1.com
http://tplus1.com
216-470-6058
Ian Bicking
2008-09-07 16:14:59 UTC
Permalink
Post by Matthew Wilson
I've got a list of checkboxes, each with the same name and the value
attribute is an integer between 1 and 10.
from formencode import validators
validators.ForEach(validators.Int(), convert_to_list=True)
I'd like to add another validator to make sure at least one checkbox is
checked, but I can't figure out how to do that.
I believe it would work to do ForEach(validators.Int(),
convert_to_list=True, not_empty=True)
--
Ian Bicking : ***@colorstudy.com : http://blog.ianbicking.org
Loading...