Skip to content

Commit

Permalink
Hide related entities if empty mootensai#132
Browse files Browse the repository at this point in the history
  • Loading branch information
drew1two committed Mar 8, 2020
1 parent a80d9c7 commit 72bfe71
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions crud/default/views/_expand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,33 @@
'content' => $this->render('_detail', [
'model' => $model,
]),
],
]
];
<?php foreach ($relations as $name => $rel): ?>
<?php if ($rel[2] && isset($rel[3]) && !in_array($name, $generator->skippedRelations)): ?>
[
'label' => '<i class="glyphicon glyphicon-book"></i> '. Html::encode(<?= $generator->generateString(Inflector::camel2words($rel[1])) ?>),
'options' => ['id' => "tab_<?= $rel[1] ?>_{$model-><?= $pk ?>}"],
'content' => $this->render('_data<?= $rel[1] ?>', [
'model' => $model,
'row' => $model-><?= $name ?>,
]),
],
if (!empty($model-><?= $name ?>)) {
$items[] =
[
'label' => '<i class="glyphicon glyphicon-book"></i> '. Html::encode(<?= $generator->generateString(Inflector::camel2words($rel[1])) ?>),
'options' => ['id' => "tab_<?= $rel[1] ?>_{$model-><?= $pk ?>}"],
'content' => $this->render('_data<?= $rel[1] ?>', [
'model' => $model,
'row' => $model-><?= $name ?>,
]),
];
}
<?php elseif(isset($rel[$generator::REL_IS_MASTER]) && !$rel[$generator::REL_IS_MASTER]): ?>
[
'label' => '<i class="glyphicon glyphicon-book"></i> '. Html::encode(<?= $generator->generateString(Inflector::camel2words($rel[1])) ?>),
'options' => ['id' => "tab_<?= $rel[1] ?>_{$model-><?= $pk ?>}"],
'content' => $this->render('_data<?= $rel[1] ?>', [
'model' => $model-><?= $name ?>
]),
],
$items[] =
[
'label' => '<i class="glyphicon glyphicon-book"></i> '. Html::encode(<?= $generator->generateString(Inflector::camel2words($rel[1])) ?>),
'options' => ['id' => "tab_<?= $rel[1] ?>_{$model-><?= $pk ?>}"],
'content' => $this->render('_data<?= $rel[1] ?>', [
'model' => $model-><?= $name ?>
]),
];
<?php endif; ?>
<?php endforeach; ?>
];

echo TabsX::widget([
'items' => $items,
'position' => TabsX::POS_ABOVE,
Expand Down

0 comments on commit 72bfe71

Please sign in to comment.