Skip to content

Commit 080271a

Browse files
committed
fix(dropdownfield,glpiselectfield): empty value parameter not honored
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
1 parent b571115 commit 080271a

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

inc/fields/dropdownfield.class.php

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ public function displayField($canEdit = true) {
136136
$id = $this->question->getID();
137137
$rand = mt_rand();
138138
$fieldName = 'formcreator_field_' . $id;
139-
$domId = $fieldName . '_' . $rand;
140139
if (!empty($this->question->fields['values'])) {
141140
$decodedValues = json_decode($this->question->fields['values'], JSON_OBJECT_AS_ARRAY);
142141
if ($decodedValues === null) {
@@ -254,6 +253,8 @@ public function displayField($canEdit = true) {
254253

255254
$dparams['condition'] = $dparams_cond_crit;
256255

256+
$dparams['display_emptychoice'] = ($this->question->fields['show_empty'] !== '0');
257+
257258
$emptyItem = new $itemtype();
258259
$emptyItem->getEmpty();
259260
$dparams['displaywith'] = [];
@@ -263,23 +264,7 @@ public function displayField($canEdit = true) {
263264
if (isset($emptyItem->fields['otherserial'])) {
264265
$dparams['displaywith'][] = 'otherserial';
265266
}
266-
if (count($dparams['displaywith']) > 0) {
267-
$dparams['itemtype'] = $itemtype;
268-
$dparams['table'] = $itemtype::getTable();
269-
$dparams['multiple'] = false;
270-
$dparams['valuename'] = Dropdown::EMPTY_VALUE;
271-
if ($dparams['value'] != 0) {
272-
$dparams['valuename'] = $dparams['value'];
273-
}
274-
echo Html::jsAjaxDropdown(
275-
$fieldName,
276-
$domId,
277-
$CFG_GLPI['root_doc']."/ajax/getDropdownFindNum.php",
278-
$dparams
279-
);
280-
} else {
281-
$itemtype::dropdown($dparams);
282-
}
267+
$itemtype::dropdown($dparams);
283268
}
284269
echo PHP_EOL;
285270
echo Html::scriptBlock("$(function() {

0 commit comments

Comments
 (0)