Skip to content

Commit af43a9c

Browse files
committed
fix(dropdownfield): display of username
in Formcreator 2.4.2, user was displayed with first and last name
1 parent 8f8d9a7 commit af43a9c

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

inc/field/dropdownfield.class.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,11 +357,17 @@ public function getRenderedHtml($domain, $canEdit = true): string {
357357
$item = new $itemtype();
358358
$value = '';
359359
if ($item->getFromDB($this->value)) {
360-
$column = 'name';
360+
$value = $item->fields['name'];
361361
if ($item instanceof CommonTreeDropdown) {
362-
$column = 'completename';
362+
$value = $item->fields['completename'];
363+
} else {
364+
/** @var CommonDBTM $item */
365+
switch ($item->getType()) {
366+
case User::class:
367+
$value = (new DbUtils())->getUserName($item->getID());
368+
break;
369+
}
363370
}
364-
$value = $item->fields[$column];
365371
}
366372

367373
return $value;

tests/3-unit/PluginFormcreatorForm.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ public function testCreateValidationNotification(User $requester, User $validato
485485

486486
$form = $this->getForm([
487487
'name' => 'validation notification',
488-
'validation_required' => \PluginFormcreatorForm_Validator::VALIDATION_USER,
488+
'validation_required' => PluginFormcreatorForm_Validator::VALIDATION_USER,
489489
'_validator_users' => [$validator->getID()],
490490
]);
491491
$this->getSection([

0 commit comments

Comments
 (0)