Skip to content

Commit

Permalink
fix(ldapselectfield): no translation for items
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Aug 3, 2022
1 parent 028a2b9 commit d170c79
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions inc/field/ldapselectfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,35 @@ public function showForm(array $options): void {
]);
}

public function getRenderedHtml($domain, $canEdit = true): string {
if (!$canEdit) {
return $this->value . PHP_EOL;
}

$html = '';
$id = $this->question->getID();
$rand = mt_rand();
$fieldName = 'formcreator_field_' . $id;
$values = $this->getAvailableValues();

if (!empty($this->question->fields['values'])) {
$html .= Dropdown::showFromArray($fieldName, $values, [
'display_emptychoice' => $this->question->fields['show_empty'] == 1,
'value' => $this->value,
'values' => [],
'rand' => $rand,
'multiple' => false,
'display' => false,
]);
}
$html .= PHP_EOL;
$html .= Html::scriptBlock("$(function() {
pluginFormcreatorInitializeSelect('$fieldName', '$rand');
});");

return $html;
}

public function getAvailableValues() {
if (empty($this->question->fields['values'])) {
return [];
Expand Down

0 comments on commit d170c79

Please sign in to comment.