diff --git a/include/class.forms.php b/include/class.forms.php index 92876b2324c7a0645c2fa63c2ee4186fa049978e..6e6537bf0b6fc8b4a95decf8842bf09dfcdf8bd5 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -800,11 +800,12 @@ class PriorityField extends ChoiceField { } function getChoices() { - $this->ht['default'] = 0; + global $cfg; + $this->ht['default'] = $cfg->getDefaultPriorityId(); $sql = 'SELECT priority_id, priority_desc FROM '.PRIORITY_TABLE .' ORDER BY priority_urgency DESC'; - $choices = array(0 => '— Default —'); + $choices = array(); if (!($res = db_query($sql))) return $choices; @@ -945,13 +946,16 @@ class ChoicesWidget extends Widget { $config = $this->field->getConfiguration(); // Determine the value for the default (the one listed if nothing is // selected) - $def_key = $this->field->get('default'); $choices = $this->field->getChoices(); + $def_key = $this->field->get('default'); $have_def = isset($choices[$def_key]); if (!$have_def) $def_val = 'Select '.$this->field->get('label'); else $def_val = $choices[$def_key]; + $value = $this->value; + if ($value === null && $have_def) + $value = $def_key; ?> <span style="display:inline-block"> <select name="<?php echo $this->name; ?>"> <?php if (!$have_def) { ?> @@ -962,7 +966,7 @@ class ChoicesWidget extends Widget { if (!$have_def && $key == $def_key) continue; ?> <option value="<?php echo $key; ?>" <?php - if ($this->value == $key) echo 'selected="selected"'; + if ($value == $key) echo 'selected="selected"'; ?>><?php echo $name; ?></option> <?php } ?> </select>