diff --git a/app/src/View/Helper/TabHelper.php b/app/src/View/Helper/TabHelper.php index 23b6adc1..b3ddcf29 100644 --- a/app/src/View/Helper/TabHelper.php +++ b/app/src/View/Helper/TabHelper.php @@ -245,11 +245,16 @@ public function getCurrentId(string $tabName = null, bool $isNested = false): in public function getHasManyAssociationModels(string $modelName): \Generator { $model = TableRegistry::getTableLocator()->get($modelName); - // We'll start by obtaining the set of models directly associated with the CO model. - $associations = $model->associations(); + // We'll start by getting the set of models directly associated with the CO model. + $associations = $model->associations()->getByType(['hasMany', 'hasOne']); + + if(empty($associations)) { + // Yield null if empty + yield; + } - foreach($associations->getByType(['hasMany', 'hasOne']) as $ta) { - $this>$this->setAssociation($ta->getClassName()); + foreach($associations as $ta) { + $this->setAssociation($ta->getClassName()); yield $ta->getClassName(); } } diff --git a/app/templates/element/subnavigation/inlineList.php b/app/templates/element/subnavigation/inlineList.php index 9a3d38d6..6fb1ef48 100644 --- a/app/templates/element/subnavigation/inlineList.php +++ b/app/templates/element/subnavigation/inlineList.php @@ -36,9 +36,21 @@ ?> + Tab->getCurrentId($tab, $isNested); + // Check if there are child models. If not continue + if (str_contains($tab, '.Hierarchy')) { + $modelName = $this->Tab->retrievePluginName($tab, (int)$curId); + [$plugin, ] = explode('.', $modelName); + if($this->Tab->getHasManyAssociationModels($modelName)->current() === null) { + continue; + } + } + + ?>