mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
Bug fixed. saveAll with validation option "only" or "first" works wll.
saveAll() did set null foreign key when it just validates. I've assigned numeric validation on the hasMany side model and validation did fail with this behavior. I've changed this not to set foreign key when it just validation.
This commit is contained in:
parent
a65a5eb506
commit
eef87ee74c
1 changed files with 9 additions and 3 deletions
|
@ -1687,7 +1687,10 @@ class Model extends Overloadable {
|
|||
$type = $associations[$association];
|
||||
switch ($type) {
|
||||
case 'hasOne':
|
||||
if (!$validating) {
|
||||
$values[$this->{$type}[$association]['foreignKey']] = $this->id;
|
||||
}
|
||||
|
||||
if (!$this->{$association}->__save($values, $options)) {
|
||||
$validationErrors[$association] = $this->{$association}->validationErrors;
|
||||
$validates = false;
|
||||
|
@ -1697,9 +1700,12 @@ class Model extends Overloadable {
|
|||
}
|
||||
break;
|
||||
case 'hasMany':
|
||||
if (!$validating) {
|
||||
foreach ($values as $i => $value) {
|
||||
$values[$i][$this->{$type}[$association]['foreignKey']] = $this->id;
|
||||
}
|
||||
}
|
||||
|
||||
$_options = array_merge($options, array('atomic' => false));
|
||||
|
||||
if ($_options['validate'] === 'first') {
|
||||
|
|
Loading…
Add table
Reference in a new issue