I haven't found any solution to my problem yet, anyone can help me? Thank you very much..
fab2008 wrote: > > Hi all, > > I've the following situation: In a form i put a multicheckbox element with > a certain number of elements say n. I'want the user select a number of > elements between x and y with 0 <= x < y <= n > > For this i've just tried to write my custom validator extending the > Zend_Validate_Between class, overriding its isValid method with something > similar to this: > > public function isValid($value) { > return parent::isValid(count($value)); > } > > because I tought that $value is an array, but it's not the case, my > validator will be called once per selected checkbox with scalar values. So > I've tried a different approach: > > protected $count = 0; > > public function isValid($value) { > if (++$this->count > $this->_max) { > return false; > } > return true; > } > > I'm unsure about correctness, it breaks if the same validator instance > will be attached to more than one multi element, and clearly it works only > for the max, but not for the min. > > Any suggestion? > > > -- View this message in context: http://www.nabble.com/Writing-a-validator-for-limit-the-number-of-selectable-elements-tp21511756p21569555.html Sent from the Zend Framework mailing list archive at Nabble.com.