Browse Source

Fix bug with adding single relation

It seems to relation with has many type would not be added if code looks like this `$model->relationName = 1` or `$model->relationName = $some model`
tags/1.1.0
Maxim 8 years ago committed by GitHub
parent
commit
1e5d7f84ec
  1. 2
      src/SaveRelationsBehavior.php

2
src/SaveRelationsBehavior.php

@ -85,7 +85,7 @@ class SaveRelationsBehavior extends Behavior
if ($relation->multiple === true) {
$newRelations = [];
if (!is_array($value)) {
$value = [];
$value = [$value];
}
foreach ($value as $entry) {
if ($entry instanceof $relation->modelClass) {

Loading…
Cancel
Save