Skip to content

Commit a9754e2

Browse files
committed
updated json editor schema widget
1 parent 75d1093 commit a9754e2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/JsonEditorSchemaWidget.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,11 @@ public function run()
6565
private function registerAssets()
6666
{
6767
$ajaxUrl = Url::to($this->ajaxUrl);
68-
$jsonEditorContainerId = Html::getInputId($this->model, $this->jsonEditorAttribute) . '-container';
68+
$jsonEditorInputId = Html::getInputId($this->model, $this->jsonEditorAttribute);
69+
$jsonEditorContainerId = $jsonEditorInputId . '-container';
6970
$select2Id = Html::getInputId($this->model, $this->attribute);
7071
$jsonEditorOptions = json_encode($this->jsonEditorOptions);
71-
72+
7273
$this->view->registerJs(<<<JS
7374
$("#{$select2Id}").on("select2:select", function () {
7475
var value = $(this).val();
@@ -89,6 +90,10 @@ private function registerAssets()
8990
9091
jsonEditors[index].destroy();
9192
jsonEditors[index] = new JSONEditor(document.getElementById("{$jsonEditorContainerId}"), jsonEditorOptions)
93+
94+
jsonEditors[index].on("change", function () {
95+
document.getElementById("{$jsonEditorInputId}").value = JSON.stringify(this.getValue());
96+
})
9297
}
9398
})
9499
});

0 commit comments

Comments
 (0)