Skip to content

Commit bda43df

Browse files
committed
fix(textareadield): missing translation for default value
1 parent 5d84054 commit bda43df

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

inc/field/textareafield.class.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,15 @@ public function getRenderedHtml($domain, $canEdit = true): string {
149149
$id = $this->question->getID();
150150
$rand = mt_rand();
151151
$fieldName = 'formcreator_field_' . $id;
152-
$value = $this->value;
152+
// Translations are saved sanitized, so we need to sanitize initial value and unsanitize translated value
153+
$defaultValue = Sanitizer::unsanitize(__(Sanitizer::sanitize($this->value), $domain));
153154
$html = '';
154155
$form = PluginFormcreatorForm::getByItem($this->getQuestion());
155156
$html .= Html::textarea([
156157
'name' => $fieldName,
157158
'editor_id' => "$fieldName$rand",
158159
'rand' => $rand,
159-
'value' => $value,
160+
'value' => $defaultValue,
160161
'rows' => 5,
161162
'display' => false,
162163
'enable_richtext' => true,

tests/3-unit/GlpiPlugin/Formcreator/Field/TextareaField.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
namespace GlpiPlugin\Formcreator\Field\tests\units;
3232
use GlpiPlugin\Formcreator\Tests\CommonTestCase;
3333
use PluginFormcreatorFormAnswer;
34-
use Glpi\Toolbox\Sanitizer;
3534

3635
class TextareaField extends CommonTestCase {
3736
public function testGetName() {

0 commit comments

Comments
 (0)