Skip to content

Commit d0c8f0e

Browse files
authored
fix(model): prevent error when displaying additional info form (#586)
* fix(model): prevent error when displaying additional info form * Update CHANGELOG.md * fix lint
1 parent 93a3ecb commit d0c8f0e

3 files changed

Lines changed: 26 additions & 31 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1313
- Rename visibility field label to "Is Private"
1414
- Restored group selection in mappings
1515
- Fix special caracters malformed in translations
16+
- Fix error when displaying the additional information form
1617

1718
## [2.15.3] - 2025-12-22
1819

inc/info.class.php

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,33 +30,8 @@
3030

3131
use Glpi\Application\View\TemplateRenderer;
3232

33-
/**
34-
* -------------------------------------------------------------------------
35-
* DataInjection plugin for GLPI
36-
* -------------------------------------------------------------------------
37-
*
38-
* LICENSE
39-
*
40-
* This file is part of DataInjection.
41-
*
42-
* DataInjection is free software; you can redistribute it and/or modify
43-
* it under the terms of the GNU General Public License as published by
44-
* the Free Software Foundation; either version 2 of the License, or
45-
* (at your option) any later version.
46-
*
47-
* DataInjection is distributed in the hope that it will be useful,
48-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
49-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50-
* GNU General Public License for more details.
51-
*
52-
* You should have received a copy of the GNU General Public License
53-
* along with DataInjection. If not, see <http://www.gnu.org/licenses/>.
54-
* -------------------------------------------------------------------------
55-
* @copyright Copyright (C) 2007-2023 by DataInjection plugin team.
56-
* @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html
57-
* @link https://github.com/pluginsGLPI/datainjection
58-
* -------------------------------------------------------------------------
59-
*/
33+
use function Safe\ob_start;
34+
use function Safe\ob_get_clean;
6035

6136
class PluginDatainjectionInfo extends CommonDBTM
6237
{
@@ -281,8 +256,19 @@ public static function showAdditionalInformationsForm(PluginDatainjectionModel $
281256
$modeltype = PluginDatainjectionModel::getInstance($model->getField('filetype'));
282257
$modeltype->getFromDBByModelID($model->getField('id'));
283258

259+
$rendered_infos = [];
260+
foreach ($infos as $info_data) {
261+
$info = new self();
262+
$info->fields = $info_data;
263+
264+
ob_start();
265+
self::displayAdditionalInformation($info, $_SESSION['datainjection']['infos'] ?? []);
266+
$rendered_infos[] = ob_get_clean();
267+
}
268+
284269
$data = [
285270
'infos' => $infos,
271+
'rendered_infos' => $rendered_infos,
286272
'model' => $model,
287273
'modeltype' => $modeltype,
288274
'has_sample' => $modeltype->haveSample(),

templates/infoadditionnalinfo.html.twig

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,17 @@
4747
</div>
4848
{% endif %}
4949

50-
{% for info in infos %}
51-
<div class="text-center mt-3">
52-
{{ self.displayAdditionalInformation(info, session_infos)|raw }}
50+
{% if rendered_infos|length > 0 %}
51+
<div class="d-flex justify-content-center mt-3">
52+
<table class="table table-borderless w-auto text-center">
53+
<tbody>
54+
{% for rendered_info in rendered_infos %}
55+
<tr>
56+
{{ rendered_info|raw }}
57+
</tr>
58+
{% endfor %}
59+
</tbody>
60+
</table>
5361
</div>
54-
{% endfor %}
62+
{% endif %}
5563
{% endif %}

0 commit comments

Comments
 (0)