From 080271ab3acb0c668028866573cf603391b5e2b6 Mon Sep 17 00:00:00 2001 From: Thierry Bugier Date: Thu, 13 Feb 2020 10:32:50 +0100 Subject: [PATCH] fix(dropdownfield,glpiselectfield): empty value parameter not honored Signed-off-by: Thierry Bugier --- inc/fields/dropdownfield.class.php | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/inc/fields/dropdownfield.class.php b/inc/fields/dropdownfield.class.php index 3ffc61581..721204975 100644 --- a/inc/fields/dropdownfield.class.php +++ b/inc/fields/dropdownfield.class.php @@ -136,7 +136,6 @@ public function displayField($canEdit = true) { $id = $this->question->getID(); $rand = mt_rand(); $fieldName = 'formcreator_field_' . $id; - $domId = $fieldName . '_' . $rand; if (!empty($this->question->fields['values'])) { $decodedValues = json_decode($this->question->fields['values'], JSON_OBJECT_AS_ARRAY); if ($decodedValues === null) { @@ -254,6 +253,8 @@ public function displayField($canEdit = true) { $dparams['condition'] = $dparams_cond_crit; + $dparams['display_emptychoice'] = ($this->question->fields['show_empty'] !== '0'); + $emptyItem = new $itemtype(); $emptyItem->getEmpty(); $dparams['displaywith'] = []; @@ -263,23 +264,7 @@ public function displayField($canEdit = true) { if (isset($emptyItem->fields['otherserial'])) { $dparams['displaywith'][] = 'otherserial'; } - if (count($dparams['displaywith']) > 0) { - $dparams['itemtype'] = $itemtype; - $dparams['table'] = $itemtype::getTable(); - $dparams['multiple'] = false; - $dparams['valuename'] = Dropdown::EMPTY_VALUE; - if ($dparams['value'] != 0) { - $dparams['valuename'] = $dparams['value']; - } - echo Html::jsAjaxDropdown( - $fieldName, - $domId, - $CFG_GLPI['root_doc']."/ajax/getDropdownFindNum.php", - $dparams - ); - } else { - $itemtype::dropdown($dparams); - } + $itemtype::dropdown($dparams); } echo PHP_EOL; echo Html::scriptBlock("$(function() {