Skip to content

Commit dec5092

Browse files
AdrienClairembaulttrasher
authored andcommitted
Fix repeatable predefined fields
1 parent 0419167 commit dec5092

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/ITILTemplateField.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ abstract class ITILTemplateField extends CommonDBChild
5454
// From CommonDBTM
5555
public $dohistory = true;
5656

57+
public static function getMultiplePredefinedValues(): array
58+
{
59+
// List of fields that are allowed to be defined multiples times.
60+
return [];
61+
}
62+
5763

5864
public function getForbiddenStandardMassiveAction()
5965
{
@@ -183,6 +189,15 @@ public static function showForITILTemplate(ITILTemplate $tt, $withtemplate = 0)
183189
$used[$data['num']] = $data['num'];
184190
}
185191

192+
// Remove fields that are allowed to have multiple values from the 'used'
193+
// list.
194+
$multiple = static::getMultiplePredefinedValues();
195+
foreach ($multiple as $val) {
196+
if (isset($used[$val])) {
197+
unset($used[$val]);
198+
}
199+
}
200+
186201
$fields_dropdown_values = [];
187202
foreach ($fields as $k => $field) {
188203
$fields_dropdown_values[$k] = $field;

src/ITILTemplatePredefinedField.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public function getPredefinedFields($ID, $withtypeandcategory = false)
202202
/**
203203
* @since 0.85
204204
**/
205-
public static function getMultiplePredefinedValues()
205+
public static function getMultiplePredefinedValues(): array
206206
{
207207

208208
$itil_class = static::$itiltype;

0 commit comments

Comments
 (0)