Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
yent authored and LouisGac committed Oct 17, 2018
1 parent 5234536 commit 2f87a0f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions application/extensions/yii-jsoneditor/JsonEditor.php
Expand Up @@ -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);
}
}
?>
?>

1 comment on commit 2f87a0f

@TonisOrmisson
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LouisGac this fix breaks using json format settings for plugins
eg for
https://github.com/TonisOrmisson/limesurvey-url-templates

Please sign in to comment.