Browse files

Trying to solve the issue ZF2-558 with the solution provided by Chris

Willis, if you set the options values and you have InArray Validator the
patch update the validator too
  • Loading branch information...
1 parent 836249f commit 294a7d18a832ce5eb297b43832c2b67db77fb425 @igormx committed Sep 18, 2012
Showing with 14 additions and 0 deletions.
  1. +7 −0 library/Zend/Form/Element/MultiCheckbox.php
  2. +7 −0 library/Zend/Form/Element/Select.php
View
7 library/Zend/Form/Element/MultiCheckbox.php
@@ -62,6 +62,13 @@ public function getValueOptions()
public function setValueOptions(array $options)
{
$this->valueOptions = $options;
+
+ // Update InArray validator haystack
+ if (!is_null($this->validator)) {
+ $validator = $this->validator->getValidator();
+ $validator->setHaystack($this->getValueOptionsValues());
+ }
+
return $this;
}
View
7 library/Zend/Form/Element/Select.php
@@ -80,6 +80,13 @@ public function getValueOptions()
public function setValueOptions(array $options)
{
$this->valueOptions = $options;
+
+ // Update InArray validator haystack
+ if (!is_null($this->validator)) {
+ $validator = $this->validator instanceof InArray ? $this->validator : $this->validator->getValidator();
+ $validator->setHaystack($this->getValueOptionsValues());
+ }
+
return $this;
}

0 comments on commit 294a7d1

Please sign in to comment.