Fixes logic error in #233

This commit is contained in:
Sam Georges 2014-05-31 10:49:14 +10:00
parent 9f30a25cf1
commit 8f007d100d
1 changed files with 1 additions and 5 deletions

View File

@ -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