Skip to content

Commit

Permalink
fix(dropdownfield): display of username
Browse files Browse the repository at this point in the history
in Formcreator 2.4.2, user was displayed with first and last name
  • Loading branch information
btry committed Oct 17, 2023
1 parent 8f8d9a7 commit af43a9c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions inc/field/dropdownfield.class.php
Expand Up @@ -357,11 +357,17 @@ public function getRenderedHtml($domain, $canEdit = true): string {
$item = new $itemtype();
$value = '';
if ($item->getFromDB($this->value)) {
$column = 'name';
$value = $item->fields['name'];
if ($item instanceof CommonTreeDropdown) {
$column = 'completename';
$value = $item->fields['completename'];
} else {
/** @var CommonDBTM $item */
switch ($item->getType()) {
case User::class:
$value = (new DbUtils())->getUserName($item->getID());
break;
}
}
$value = $item->fields[$column];
}

return $value;
Expand Down
2 changes: 1 addition & 1 deletion tests/3-unit/PluginFormcreatorForm.php
Expand Up @@ -485,7 +485,7 @@ public function testCreateValidationNotification(User $requester, User $validato

$form = $this->getForm([
'name' => 'validation notification',
'validation_required' => \PluginFormcreatorForm_Validator::VALIDATION_USER,
'validation_required' => PluginFormcreatorForm_Validator::VALIDATION_USER,
'_validator_users' => [$validator->getID()],
]);
$this->getSection([
Expand Down

0 comments on commit af43a9c

Please sign in to comment.