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 Mar 20, 2020
1 parent 056b419 commit 187daa5
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 @@ -153,7 +153,6 @@ public function getRenderedHtml($canEdit = true) {
$id = $this->question->getID();
$rand = mt_rand();
$fieldName = 'formcreator_field_' . $id;
$domId = $fieldName . '_' . $rand;
if (!empty($this->question->fields['values'])) {
$dparams = ['name' => $fieldName,
'value' => $this->value,
Expand Down Expand Up @@ -265,6 +264,8 @@ public function getRenderedHtml($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 @@ -274,23 +275,7 @@ public function getRenderedHtml($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'];
}
$html .= Html::jsAjaxDropdown(
$fieldName,
$domId,
$CFG_GLPI['root_doc']."/ajax/getDropdownFindNum.php",
$dparams
);
} else {
$html .= $itemtype::dropdown($dparams);
}
$itemtype::dropdown($dparams);
}
$html .= PHP_EOL;
$html .= Html::scriptBlock("$(function() {
Expand Down

0 comments on commit 187daa5

Please sign in to comment.