Skip to content

Commit

Permalink
fix(textareadield): missing translation for default value
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Oct 10, 2023
1 parent 5d84054 commit bda43df
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
5 changes: 3 additions & 2 deletions inc/field/textareafield.class.php
Expand Up @@ -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,
Expand Down
Expand Up @@ -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() {
Expand Down

0 comments on commit bda43df

Please sign in to comment.