diff --git a/modules/backend/behaviors/RelationController.php b/modules/backend/behaviors/RelationController.php index fb8d5d17f..c994df124 100644 --- a/modules/backend/behaviors/RelationController.php +++ b/modules/backend/behaviors/RelationController.php @@ -578,7 +578,6 @@ class RelationController extends ControllerBehavior */ $widget = $this->makeWidget('Backend\Widgets\Lists', $config); $widget->bindEvent('list.extendQuery', function ($query) { - $this->controller->relationExtendQuery($query, $this->field); $this->relationObject->setQuery($query); $sessionKey = $this->deferredBinding ? $this->relationGetSessionKey() : null; @@ -590,6 +589,8 @@ class RelationController extends ControllerBehavior $this->relationObject->addConstraints(); } + $this->controller->relationExtendQuery($query, $this->field); + /* * Allows pivot data to enter the fray */ @@ -722,8 +723,6 @@ class RelationController extends ControllerBehavior */ if ($this->manageMode == 'pivot' || $this->manageMode == 'list') { $widget->bindEvent('list.extendQuery', function ($query) { - $this->controller->relationExtendQuery($query, $this->field); - /* * Where not in the current list of related records */ @@ -732,6 +731,7 @@ class RelationController extends ControllerBehavior $query->whereNotIn($this->relationModel->getQualifiedKeyName(), $existingIds); } + $this->controller->relationExtendQuery($query, $this->field); }); }