Permalink
Browse files

Improved previous fix for ZF2-558. Previous fix made implicit assumpt…

…ions that could cause issues in subclasses of Element\[Select|MultiCheckbox]
  • Loading branch information...
1 parent d33aed6 commit bc0333ab4c563bd6dd4b40fa54bd6ab13d2fb5c4 Tim Lieberman committed Sep 27, 2012
Showing with 10 additions and 3 deletions.
  1. +1 −1 library/Zend/Form/Element/MultiCheckbox.php
  2. +9 −2 library/Zend/Form/Element/Select.php
View
2 library/Zend/Form/Element/MultiCheckbox.php
@@ -64,7 +64,7 @@ public function setValueOptions(array $options)
$this->valueOptions = $options;
// Update InArray validator haystack
- if (!is_null($this->validator)) {
+ if (!is_null($this->validator) && $this->validator instanceof ExplodeValidator) {
$validator = $this->validator->getValidator();
$validator->setHaystack($this->getValueOptionsValues());
}
View
11 library/Zend/Form/Element/Select.php
@@ -83,8 +83,15 @@ public function setValueOptions(array $options)
// Update InArrayValidator validator haystack
if (!is_null($this->validator)) {
- $validator = $this->validator instanceof InArrayValidator ? $this->validator : $this->validator->getValidator();
- $validator->setHaystack($this->getValueOptionsValues());
+ if ($this->validator instanceof InArrayValidator){
+ $validator = $this->validator;
+ }
+ if ($this->validator instanceof ExplodeValidator){
+ $validator = $this->validator->getValidator();
+ }
+ if (!empty($validator)){
+ $validator->setHaystack($this->getValueOptionsValues());
+ }
}
return $this;

0 comments on commit bc0333a

Please sign in to comment.