Skip to content

Commit

Permalink
fix(dropdownfield,glpiselectfield): empty value parameter not honored
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Feb 24, 2020
1 parent b571115 commit 080271a
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions inc/fields/dropdownfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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'] = [];
Expand All @@ -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() {
Expand Down

0 comments on commit 080271a

Please sign in to comment.