Skip to content

Commit 12a02fe

Browse files
committed
fix(dropdownfield,glpiselectfield): empty value parameter not honored
Signed-off-by: Thierry Bugier <[email protected]>
1 parent 718724e commit 12a02fe

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
@@ -138,7 +138,6 @@ public function displayField($canEdit = true) {
138138
$id = $this->question->getID();
139139
$rand = mt_rand();
140140
$fieldName = 'formcreator_field_' . $id;
141-
$domId = $fieldName . '_' . $rand;
142141
if (!empty($this->question->fields['values'])) {
143142
$decodedValues = json_decode($this->question->fields['values'], JSON_OBJECT_AS_ARRAY);
144143
$itemtype = $this->getSubItemtype();
@@ -251,6 +250,8 @@ public function displayField($canEdit = true) {
251250

252251
$dparams['condition'] = $dparams_cond_crit;
253252

253+
$dparams['display_emptychoice'] = ($this->question->fields['show_empty'] !== '0');
254+
254255
$emptyItem = new $itemtype();
255256
$emptyItem->getEmpty();
256257
$dparams['displaywith'] = [];
@@ -260,23 +261,7 @@ public function displayField($canEdit = true) {
260261
if (isset($emptyItem->fields['otherserial'])) {
261262
$dparams['displaywith'][] = 'otherserial';
262263
}
263-
if (count($dparams['displaywith']) > 0) {
264-
$dparams['itemtype'] = $itemtype;
265-
$dparams['table'] = $itemtype::getTable();
266-
$dparams['multiple'] = false;
267-
$dparams['valuename'] = Dropdown::EMPTY_VALUE;
268-
if ($dparams['value'] != 0) {
269-
$dparams['valuename'] = $dparams['value'];
270-
}
271-
echo Html::jsAjaxDropdown(
272-
$fieldName,
273-
$domId,
274-
$CFG_GLPI['root_doc']."/ajax/getDropdownFindNum.php",
275-
$dparams
276-
);
277-
} else {
278-
$itemtype::dropdown($dparams);
279-
}
264+
$itemtype::dropdown($dparams);
280265
}
281266
echo PHP_EOL;
282267
echo Html::scriptBlock("$(function() {

0 commit comments

Comments
 (0)