diff options
-rw-r--r-- | fai_gestion/plugins/CustomTheme/src/Template/Bake/Template/view.twig | 5 | ||||
-rw-r--r-- | fai_gestion/plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php | 18 |
2 files changed, 21 insertions, 2 deletions
diff --git a/fai_gestion/plugins/CustomTheme/src/Template/Bake/Template/view.twig b/fai_gestion/plugins/CustomTheme/src/Template/Bake/Template/view.twig index a5563bf..0b2dd28 100644 --- a/fai_gestion/plugins/CustomTheme/src/Template/Bake/Template/view.twig +++ b/fai_gestion/plugins/CustomTheme/src/Template/Bake/Template/view.twig @@ -149,19 +149,20 @@ {% for alias, details in relations %} {% set otherSingularVar = alias|variable %} {% set otherPluralHumanName = details.controller|underscore|humanize %} +{% set fields = BakeExtra.filterFieldsOther(details.fields, details.controller) %} <div class="related"> <h4><?= __('Related {{ otherPluralHumanName }}') ?></h4> <?php if (!empty(${{ singularVar }}->{{ details.property }})): ?> <table cellpadding="0" cellspacing="0"> <tr> -{% for field in details.fields %} +{% for field in fields %} <th scope="col"><?= __('{{ field|humanize }}') ?></th> {% endfor %} <th scope="col" class="actions"><?= __('Actions') ?></th> </tr> <?php foreach (${{ singularVar }}->{{ details.property }} as ${{ otherSingularVar }}): ?> <tr> -{% for field in details.fields %} +{% for field in fields %} <td><?= h(${{ otherSingularVar }}->{{ field }}) ?></td> {% endfor %} {% set otherPk = '$' ~ otherSingularVar ~ '->' ~ details.primaryKey[0] %} diff --git a/fai_gestion/plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php b/fai_gestion/plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php index 44b28d4..a495973 100644 --- a/fai_gestion/plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php +++ b/fai_gestion/plugins/CustomTheme/src/View/Helper/BakeExtraHelper.php @@ -104,6 +104,24 @@ class BakeExtraHelper extends Helper return $coll->take($takeFields)->toArray(); } + + public function filterFieldsOther($fields, $controllerName) { + + $takeFields = Hash::get($this->_config, "taskParams.$controllerName.index-columns"); + if ( $takeFields === NULL ) + $takeFields = Hash::get($this->_config, "taskParams.default.index-columns"); + //$filterTypes = ['binary']; // TODO + $rejectFields = ['id']; + + $coll = collection($fields); + $coll = $coll->reject(function ($field, $key) use ($rejectFields) { + return in_array($field, $rejectFields); + }); + + return $coll->take($takeFields)->toArray(); + } + + public function getTitleOpts($controllerName) { if ( ! is_string($controllerName) ) return FALSE; return Hash::get($this->_config, "templateExtra.$controllerName.title"); |