From 2f87a0fb3271579a23c7e6a9fcd7027335bb7e5f Mon Sep 17 00:00:00 2001 From: yent Date: Wed, 17 Oct 2018 16:46:12 +0200 Subject: [PATCH] Fixed issue: JSON editor options to load the right content (#1130) Fixed issue: content, whatever its type, was passed to CHtml::encode which expects a string due to lack of encode htmlOption for CHtml::textarea. Also added needed json_encode so that textarea value is a string in the end. --- application/extensions/yii-jsoneditor/JsonEditor.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/application/extensions/yii-jsoneditor/JsonEditor.php b/application/extensions/yii-jsoneditor/JsonEditor.php index 8fb65e1e568..c5a166a692b 100644 --- a/application/extensions/yii-jsoneditor/JsonEditor.php +++ b/application/extensions/yii-jsoneditor/JsonEditor.php @@ -47,11 +47,12 @@ public function run() { $htmlOptions = $this->htmlOptions; list($name, $id) = $this->resolveNameID(); - echo CHtml::tag('div', $htmlOptions, CHtml::textArea($name, $this->value, array( - 'id' => $id + echo CHtml::tag('div', $htmlOptions, CHtml::textArea($name, json_encode($this->value), array( + 'id' => $id, + 'encode' => false, ))); $config = json_encode($this->editorOptions); App()->getClientScript()->registerScript("initJsonEditor" . $id, "$('#{$id}').jsonEditor($config);", CClientScript::POS_READY); } } -?> \ No newline at end of file +?>