Skip to content

Commit 40c9ab7

Browse files
committed
fix(glpiselectfield): missing entity restrict
1 parent 692940a commit 40c9ab7

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

inc/field/dropdownfield.class.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public function showForm(array $options): void {
8383
$template = '@formcreator/field/' . $this->question->fields['fieldtype'] . 'field.html.twig';
8484

8585
$decodedValues = json_decode($this->question->fields['values'], JSON_OBJECT_AS_ARRAY);
86+
8687
$this->question->fields['_tree_root'] = $decodedValues['show_tree_root'] ?? Dropdown::EMPTY_VALUE;
8788
$this->question->fields['_tree_root_selectable'] = $decodedValues['selectable_tree_root'] ?? '0';
8889
$this->question->fields['_tree_max_depth'] = $decodedValues['show_tree_depth'] ?? Dropdown::EMPTY_VALUE;

inc/field/glpiselectfield.class.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
use Dropdown;
3838
use Entity;
3939
use CommonTreeDropdown;
40+
use CommonDBTM;
4041

4142
use GlpiPlugin\Formcreator\Exception\ComparisonException;
4243
use Glpi\Application\View\TemplateRenderer;
@@ -48,16 +49,21 @@ public function showForm(array $options): void {
4849

4950
$decodedValues = json_decode($this->question->fields['values'], JSON_OBJECT_AS_ARRAY);
5051

51-
$this->question->fields['_is_tree'] = '0';
5252
$this->question->fields['_tree_root'] = $decodedValues['show_tree_root'] ?? Dropdown::EMPTY_VALUE;
5353
$this->question->fields['_tree_root_selectable'] = $decodedValues['selectable_tree_root'] ?? '0';
5454
$this->question->fields['_tree_max_depth'] = $decodedValues['show_tree_depth'] ?? Dropdown::EMPTY_VALUE;
55+
$this->question->fields['_entity_restrict'] = $decodedValues['entity_restrict'] ?? self::ENTITY_RESTRICT_FORM;
56+
$this->question->fields['_is_tree'] = '0';
5557
$this->question->fields['_is_entity_restrict'] = '0';
56-
if (isset($this->question->fields['itemtype']) && is_subclass_of($this->question->fields['itemtype'], CommonTreeDropdown::class)) {
57-
$this->question->fields['_is_tree'] = '1';
58+
if (isset($this->question->fields['itemtype']) && is_subclass_of($this->question->fields['itemtype'], CommonDBTM::class)) {
5859
$item = new $this->question->fields['itemtype'];
5960
$this->question->fields['_is_entity_restrict'] = $item->isEntityAssign() ? '1' : '0';
6061
}
62+
if (isset($this->question->fields['itemtype']) && is_subclass_of($this->question->fields['itemtype'], CommonTreeDropdown::class)) {
63+
$this->question->fields['_is_tree'] = '1';
64+
// $item = new $this->question->fields['itemtype'];
65+
// $this->question->fields['_is_entity_restrict'] = $item->isEntityAssign() ? '1' : '0';
66+
}
6167
$this->question->fields['default_values'] = Html::entities_deep($this->question->fields['default_values']);
6268
$this->deserializeValue($this->question->fields['default_values']);
6369

0 commit comments

Comments
 (0)