Skip to content

Commit 187daa5

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

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
@@ -153,7 +153,6 @@ public function getRenderedHtml($canEdit = true) {
153153
$id = $this->question->getID();
154154
$rand = mt_rand();
155155
$fieldName = 'formcreator_field_' . $id;
156-
$domId = $fieldName . '_' . $rand;
157156
if (!empty($this->question->fields['values'])) {
158157
$dparams = ['name' => $fieldName,
159158
'value' => $this->value,
@@ -265,6 +264,8 @@ public function getRenderedHtml($canEdit = true) {
265264

266265
$dparams['condition'] = $dparams_cond_crit;
267266

267+
$dparams['display_emptychoice'] = ($this->question->fields['show_empty'] !== '0');
268+
268269
$emptyItem = new $itemtype();
269270
$emptyItem->getEmpty();
270271
$dparams['displaywith'] = [];
@@ -274,23 +275,7 @@ public function getRenderedHtml($canEdit = true) {
274275
if (isset($emptyItem->fields['otherserial'])) {
275276
$dparams['displaywith'][] = 'otherserial';
276277
}
277-
if (count($dparams['displaywith']) > 0) {
278-
$dparams['itemtype'] = $itemtype;
279-
$dparams['table'] = $itemtype::getTable();
280-
$dparams['multiple'] = false;
281-
$dparams['valuename'] = Dropdown::EMPTY_VALUE;
282-
if ($dparams['value'] != 0) {
283-
$dparams['valuename'] = $dparams['value'];
284-
}
285-
$html .= Html::jsAjaxDropdown(
286-
$fieldName,
287-
$domId,
288-
$CFG_GLPI['root_doc']."/ajax/getDropdownFindNum.php",
289-
$dparams
290-
);
291-
} else {
292-
$html .= $itemtype::dropdown($dparams);
293-
}
278+
$itemtype::dropdown($dparams);
294279
}
295280
$html .= PHP_EOL;
296281
$html .= Html::scriptBlock("$(function() {

0 commit comments

Comments
 (0)