Validator - not able to add multiple rules at once for a single field #956

Closed
wants to merge 1 commit into
from
View
9 lib/Cake/Model/Validator/CakeValidationSet.php
@@ -235,10 +235,11 @@ public function removeRule($name) {
* @return ModelField
*/
public function setRules($rules = array(), $mergeVars = true) {
- if ($mergeVars === false) {
- $this->_rules = $rules;
- } else {
- $this->_rules = array_merge($this->_rules, $rules);
+ if($mergeVars === false) {
+ $this->_rules = array();
+ }
+ foreach($rules as $name => $rule) {
+ $this->setRule($name, $rule);
}
return $this;
}