Skip to content

Commit

Permalink
fix(dropdownfield): entity restriction relative to the form, not the …
Browse files Browse the repository at this point in the history
…user

fix #2047

Signed-off-by: Thierry Bugier <[email protected]>
  • Loading branch information
btry committed Jan 6, 2021
1 parent 63f90f0 commit 358b78a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions inc/field/dropdownfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
namespace GlpiPlugin\Formcreator\Field;

use PluginFormcreatorAbstractField;
use PluginFormcreatorForm;
use Html;
use Toolbox;
use Session;
Expand Down Expand Up @@ -192,12 +193,15 @@ public function buildParams($rand = null) {
$fieldName = 'formcreator_field_' . $id;
$itemtype = $this->getSubItemtype();

$form = new PluginFormcreatorForm();
$form->getFromDBByQuestion($this->getQuestion());
$dparams = [
'name' => $fieldName,
'value' => $this->value,
'display' => false,
'comments' => false,
'entity' => $_SESSION['glpiactiveentities'],
'entity' => $form->fields['entities_id'],
'entity_sons' => (bool) $form->isRecursive(),
'displaywith' => ['id'],
];

Expand Down Expand Up @@ -368,7 +372,8 @@ public function getRenderedHtml($canEdit = true): string {
$fieldName = 'formcreator_field_' . $id;
if (!empty($this->question->fields['values'])) {
$dparams = $this->buildParams($rand);
$html .= $itemtype::dropdown($dparams + ['display' => false]);
$dparams['display'] = false;
$html .= $itemtype::dropdown($dparams);
}
$html .= PHP_EOL;
$html .= Html::scriptBlock("$(function() {
Expand Down

0 comments on commit 358b78a

Please sign in to comment.