Permalink
Browse files

Ugly hack to fix saveAll deep and beforeValidate callbacks changing m…

…odel data
  • Loading branch information...
lorenzo committed May 10, 2012
1 parent 00a34f1 commit 6da2fe8323403545220a751bac9c280fb2b1a190
Showing with 10 additions and 1 deletion.
  1. +10 −1 lib/Cake/Model/Model.php
View
@@ -2324,7 +2324,16 @@ public function validateAssociated(&$data, $options = array()) {
} else {
$return[$this->alias] = true;
}
- $data[$this->alias] = $this->data[$this->alias];
+
+ if (empty($options['deep'])) {
+ $data[$this->alias] = $this->data[$this->alias];
+ } else {
+ $modelData = $this->data;
+ $recordData = $modelData[$this->alias];
+ unset($modelData[$this->alias]);
+ $data = $modelData + array_merge($data, $recordData);
+ }
+
$associations = $this->getAssociated();
foreach ($data as $association => &$values) {
$validates = true;

0 comments on commit 6da2fe8

Please sign in to comment.