--- laboratory/Zend/Form/Element/Multi.php.dist 2008-01-07 19:53:25.000000000 +0100 +++ laboratory/Zend/Form/Element/Multi.php 2008-01-07 20:29:57.000000000 +0100 @@ -47,6 +47,12 @@ protected $_separator = '
'; /** + * Array of multi-item-specific errors + * @var array + */ + protected $_multi_errors = array(); + + /** * Retrieve separator * * @return mixed @@ -112,5 +118,29 @@ $this->_options = array(); return $this; } -} + /** + * Retrieve validation errors, if any + * + * @return array + */ + public function getErrors() + { + return $this->_multi_errors + $this->getValidatorChain()->getMessages(); + } + + /** + * Validate element + * + * @param mixed $value + * @return bool + */ + public function isValid($value = null) + { + if (! isset($this->_options[$value])) { + $this->_multi_errors[] = 'Chosen value is not available'; + return false; + } + return $this->getValidatorChain()->isValid($value); + } +}