|
|
@ -168,6 +168,14 @@ class SaveRelationsBehavior extends Behavior |
|
|
|
if (is_array($data)) { |
|
|
|
if (is_array($data)) { |
|
|
|
$fks = []; |
|
|
|
$fks = []; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// search PK |
|
|
|
|
|
|
|
foreach($modelClass::primaryKey() as $modelAttribute) { |
|
|
|
|
|
|
|
if (array_key_exists($modelAttribute, $data) && !empty($data[$modelAttribute])) { |
|
|
|
|
|
|
|
$fks[$modelAttribute] = $data[$modelAttribute]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!$fks) { |
|
|
|
// Get the right link definition |
|
|
|
// Get the right link definition |
|
|
|
if ($relation->via instanceof BaseActiveRecord) { |
|
|
|
if ($relation->via instanceof BaseActiveRecord) { |
|
|
|
$viaQuery = $relation->via; |
|
|
|
$viaQuery = $relation->via; |
|
|
@ -184,6 +192,7 @@ class SaveRelationsBehavior extends Behavior |
|
|
|
$fks[$modelAttribute] = $data[$modelAttribute]; |
|
|
|
$fks[$modelAttribute] = $data[$modelAttribute]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$fks = $data; |
|
|
|
$fks = $data; |
|
|
|
} |
|
|
|
} |
|
|
|