Hi
I've write a validator called "ADM_Validate_ArrayCount" that acts like
StringLength but with arrays. I want to know if a "select multiple" from a
form has 1,2,..N selected elements.
Looking at the Zend_Form_Element source code I see the isValid method and
it's doing something i cannot understand why.
This is the piece of code:
foreach ($this->getValidators() as $key => $validator) {
if (method_exists($validator, 'setTranslator')) {
$validator->setTranslator($translator);
}
if ($isArray && is_array($value)) {
$messages = array();
$errors = array();
foreach ($value as $val) {
if (!$validator->isValid($val, $context)) {
$result = false;
$messages = array_merge($messages,
$validator->getMessages());
$errors = array_merge($errors,
$validator->getErrors());
}
}
if ($result) {
continue;
}
}
If the received value is an array, why is forcing me to validate each
element? maybe we need some flag to define if we want to validate the whole
array at once or each element with the validator.
Of course, I can extend Zend_Form_Element and override the "isValid" method
but I want to know how you're validating multiple selects (apart from
notEmpty validators...).
Thanks !
--
Xavier Vidal Piera
Enginyer Tècnic Informàtic de Gestió
Tècnic Especialista Informàtic d'equips
[EMAIL PROTECTED]
[EMAIL PROTECTED]
http://web.xaviervidal.net
610.68.41.78