From d2eb4e21419a63ea2a7c0e9d633164ec38550c32 Mon Sep 17 00:00:00 2001 From: Sam Georges Date: Fri, 20 Jun 2014 19:30:20 +1000 Subject: [PATCH] Add noRecordsMessage to RelationController behavior --- modules/backend/behaviors/RelationController.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/backend/behaviors/RelationController.php b/modules/backend/behaviors/RelationController.php index 2c659d919..0731cf214 100644 --- a/modules/backend/behaviors/RelationController.php +++ b/modules/backend/behaviors/RelationController.php @@ -47,6 +47,11 @@ class RelationController extends ControllerBehavior */ protected $requiredProperties = ['relationConfig']; + /** + * @var array Properties that must exist for each relationship definition. + */ + protected $requiredRelationProperties = ['label']; + /** * @var array Configuration values that must exist when applying the primary config file. */ @@ -150,7 +155,7 @@ class RelationController extends ControllerBehavior throw new ApplicationException(Lang::get('backend::lang.relation.missing_definition', compact('field'))); $this->alias = camel_case('relation ' . $field); - $this->config = (object)$this->getConfig($field); + $this->config = $this->makeConfig($this->getConfig($field), $this->requiredRelationProperties); /* * Relationship details @@ -504,7 +509,9 @@ class RelationController extends ControllerBehavior ]; $toolbarConfig = $this->makeConfig($this->getConfig('toolbar', $defaultConfig)); $toolbarConfig->alias = $this->alias . 'Toolbar'; - return $this->makeWidget('Backend\Widgets\Toolbar', $toolbarConfig); + + $toolbarWidget = $this->makeWidget('Backend\Widgets\Toolbar', $toolbarConfig); + return $toolbarWidget; } protected function makeViewWidget() @@ -516,6 +523,7 @@ class RelationController extends ControllerBehavior $config = $this->makeConfig($this->config->list); $config->model = $this->relationModel; $config->alias = $this->alias . 'ViewList'; + $config->noRecordsMessage = $this->config->emptyMessage; $config->recordOnClick = sprintf("$.oc.relationBehavior.clickManageListRecord('%s', :id)", $this->field); $config->showCheckboxes = true;