From 13b14729fd04a345a9735256c6d657969634a661 Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Mon, 6 Apr 2015 16:57:53 +1000 Subject: [PATCH] Don't allow a record to be clicked if there is no form to display --- modules/backend/behaviors/RelationController.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/modules/backend/behaviors/RelationController.php b/modules/backend/behaviors/RelationController.php index 0c5d97140..d26dddedd 100644 --- a/modules/backend/behaviors/RelationController.php +++ b/modules/backend/behaviors/RelationController.php @@ -561,6 +561,12 @@ class RelationController extends ControllerBehavior if ($config->recordUrl) { $defaultOnClick = null; } + elseif ( + !$this->makeConfigForMode('manage', 'form', false) && + !$this->makeConfigForMode('pivot', 'form', false) + ) { + $defaultOnClick = null; + } $config->recordOnClick = $this->getConfig('view[recordOnClick]', $defaultOnClick); @@ -1267,7 +1273,7 @@ class RelationController extends ControllerBehavior * Returns the configuration for a mode (view, manage, pivot) for an * expected type (list, form). Uses fallback configuration. */ - protected function makeConfigForMode($mode = 'view', $type = 'list') + protected function makeConfigForMode($mode = 'view', $type = 'list', $throwException = true) { $config = null; @@ -1293,12 +1299,16 @@ class RelationController extends ControllerBehavior * - view.list => manage.list */ if (!$config) { - if ($mode == 'manage' && $type == 'list') { return $this->makeConfigForMode('view', $type); } - throw new ApplicationException('Missing configuration for '.$mode.'.'.$type.' in RelationController definition '.$this->field); + if ($throwException) { + throw new ApplicationException('Missing configuration for '.$mode.'.'.$type.' in RelationController definition '.$this->field); + } + else { + return false; + } } return $this->makeConfig($config);