From d170c79c1ed2debd1f3cd2b41ddeba0cc475223d Mon Sep 17 00:00:00 2001 From: Thierry Bugier Date: Tue, 2 Aug 2022 21:32:54 +0200 Subject: [PATCH] fix(ldapselectfield): no translation for items --- inc/field/ldapselectfield.class.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/inc/field/ldapselectfield.class.php b/inc/field/ldapselectfield.class.php index e6e983a84..27670a5d1 100644 --- a/inc/field/ldapselectfield.class.php +++ b/inc/field/ldapselectfield.class.php @@ -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 [];