mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-06 03:22:39 +00:00
Modifying Controller::validateErrors so it can accept and validate arbitrary model objects, not just those attached to the controller. Test cases updated, fixes #832
This commit is contained in:
parent
50144d6b5b
commit
2db510d1c1
2 changed files with 23 additions and 3 deletions
|
@ -843,8 +843,11 @@ class Controller extends Object {
|
|||
|
||||
$errors = array();
|
||||
foreach ($objects as $object) {
|
||||
$this->{$object->alias}->set($object->data);
|
||||
$errors = array_merge($errors, $this->{$object->alias}->invalidFields());
|
||||
if (isset($this->{$object->alias})) {
|
||||
$object =& $this->{$object->alias};
|
||||
}
|
||||
$object->set($object->data);
|
||||
$errors = array_merge($errors, $object->invalidFields());
|
||||
}
|
||||
|
||||
return $this->validationErrors = (!empty($errors) ? $errors : false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue