diff --git a/include/class.forms.php b/include/class.forms.php index 2ed396a1c2a06c39ff0b3635cc229362db129388..46f76905a3c866f34fff19826b67297c1c442d9e 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -1166,8 +1166,8 @@ class ThreadEntryField extends FormField { } class PriorityField extends ChoiceField { - function getWidget() { - $widget = parent::getWidget(); + function getWidget($widgetClass=false) { + $widget = parent::getWidget($widgetClass); if ($widget->value instanceof Priority) $widget->value = $widget->value->getId(); return $widget; @@ -1181,13 +1181,10 @@ class PriorityField extends ChoiceField { $this->get('name') != 'priority'; } - function getChoices() { - global $cfg; - $this->ht['default'] = $cfg->getDefaultPriorityId(); - + function getChoices($verbose=false) { $sql = 'SELECT priority_id, priority_desc FROM '.PRIORITY_TABLE .' ORDER BY priority_urgency DESC'; - $choices = array(); + $choices = array('' => '— '.__('Default').' —'); if (!($res = db_query($sql))) return $choices; @@ -1227,14 +1224,31 @@ class PriorityField extends ChoiceField { } function getConfigurationOptions() { + $choices = $this->getChoices(); + $choices[''] = __('System Default'); return array( 'prompt' => new TextboxField(array( 'id'=>2, 'label'=>__('Prompt'), 'required'=>false, 'default'=>'', 'hint'=>__('Leading text shown before a value is selected'), 'configuration'=>array('size'=>40, 'length'=>40), )), + 'default' => new ChoiceField(array( + 'id'=>3, 'label'=>__('Default'), 'required'=>false, 'default'=>'', + 'choices' => $choices, + 'hint'=>__('Default selection for this field'), + 'configuration'=>array('size'=>20, 'length'=>40), + )), ); } + + function getConfiguration() { + global $cfg; + + $config = parent::getConfiguration(); + if (!isset($config['default'])) + $config['default'] = $cfg->getDefaultPriorityId(); + return $config; + } } FormField::addFieldTypes(/*@trans*/ 'Dynamic Fields', function() { return array( @@ -1275,7 +1289,7 @@ class TicketStateField extends ChoiceField { return false; } - function getChoices() { + function getChoices($verbose=false) { static $_choices; if (!isset($_choices)) { @@ -1359,7 +1373,7 @@ class TicketFlagField extends ChoiceField { return true; } - function getChoices() { + function getChoices($verbose=false) { $this->ht['default'] = ''; if (!$this->_choices) {