diff --git a/inc/field/textareafield.class.php b/inc/field/textareafield.class.php index 26613b5eb..0c7e9153a 100644 --- a/inc/field/textareafield.class.php +++ b/inc/field/textareafield.class.php @@ -149,14 +149,15 @@ public function getRenderedHtml($domain, $canEdit = true): string { $id = $this->question->getID(); $rand = mt_rand(); $fieldName = 'formcreator_field_' . $id; - $value = $this->value; + // Translations are saved sanitized, so we need to sanitize initial value and unsanitize translated value + $defaultValue = Sanitizer::unsanitize(__(Sanitizer::sanitize($this->value), $domain)); $html = ''; $form = PluginFormcreatorForm::getByItem($this->getQuestion()); $html .= Html::textarea([ 'name' => $fieldName, 'editor_id' => "$fieldName$rand", 'rand' => $rand, - 'value' => $value, + 'value' => $defaultValue, 'rows' => 5, 'display' => false, 'enable_richtext' => true, diff --git a/tests/3-unit/GlpiPlugin/Formcreator/Field/TextareaField.php b/tests/3-unit/GlpiPlugin/Formcreator/Field/TextareaField.php index 813346869..a7a906555 100644 --- a/tests/3-unit/GlpiPlugin/Formcreator/Field/TextareaField.php +++ b/tests/3-unit/GlpiPlugin/Formcreator/Field/TextareaField.php @@ -31,7 +31,6 @@ namespace GlpiPlugin\Formcreator\Field\tests\units; use GlpiPlugin\Formcreator\Tests\CommonTestCase; use PluginFormcreatorFormAnswer; -use Glpi\Toolbox\Sanitizer; class TextareaField extends CommonTestCase { public function testGetName() {