diff --git a/modules/backend/formwidgets/Relation.php b/modules/backend/formwidgets/Relation.php index 21c3544cc..451b35c34 100644 --- a/modules/backend/formwidgets/Relation.php +++ b/modules/backend/formwidgets/Relation.php @@ -91,7 +91,7 @@ class Relation extends FormWidgetBase $relatedObj = $this->model->makeRelation($this->relationName); $query = $relatedObj->newQuery(); - if ($this->relationType == 'belongsToMany') { + if (in_array($this->relationType, ['belongsToMany', 'morphToMany', 'morphedByMany'])) { $field->type = 'checkboxlist'; $field->value = $relationObj->getRelatedIds(); } @@ -101,10 +101,6 @@ class Relation extends FormWidgetBase $foreignKey = $relationObj->getForeignKey(); $field->value = $this->model->$foreignKey; } - else if ($this->relationType == ('morphToMany' || 'morphedByMany')) { - $field->type = 'checkboxlist'; - $field->value = $relationObj->getRelatedIds(); - } // It is safe to assume that if the model and related model are of // the exact same class, then it cannot be related to itself