Skip to content

Commit

Permalink
fix(urgencyfield): default value
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Dec 13, 2018
1 parent 167c43f commit 1849e61
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
7 changes: 5 additions & 2 deletions inc/fields/urgencyfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public static function getName() {
}

public function prepareQuestionInputForSave($input) {
$this->value = $input['default_values'] != ''
? (int) $input['default_values']
: '3';
return $input;
}

Expand Down Expand Up @@ -103,7 +106,7 @@ public function getAvailableValues() {

public function serializeValue() {
if ($this->value === null || $this->value === '') {
return '';
return '3';
}

return $this->value;
Expand All @@ -112,7 +115,7 @@ public function serializeValue() {
public function deserializeValue($value) {
$this->value = ($value !== null && $value !== '')
? $value
: '';
: '3';
}

public function getValueForDesign() {
Expand Down
4 changes: 2 additions & 2 deletions inc/question.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ public static function showForForm(CommonDBTM $item, $withtemplate = '') {

/**
* Validate form fields before add or update a question
* @param Array $input Datas used to add the item
* @return Array The modified $input array
* @param array $input Datas used to add the item
* @return array The modified $input array
*/
private function checkBeforeSave($input) {
// Control fields values :
Expand Down
1 change: 1 addition & 0 deletions tests/suite-integration/PluginFormcreatorTargetTicket.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public function testUrgency() {
[
'name' => 'custom urgency',
'fieldtype' => 'urgency',
'default_values' => '3',
],
],
],
Expand Down

0 comments on commit 1849e61

Please sign in to comment.