Skip to content

Commit 56b0f22

Browse files
Ram Krishna Banstolajxlwqq
Ram Krishna Banstola
authored andcommitted
Create individual instance of editor for column
Currently if there are more than one editor in a page then the content from the last editor is overrides content of all other editor on submit. This happens because editor is overridden. $form->json('first_json_mapping_field', 'First'); $form->json('second_json_mapping_field','Second'); --->Submit the form and both the fields will have save data saved
1 parent 39cdcfd commit 56b0f22

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Editor.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ public function render()
3838
// create the editor
3939
var container = document.getElementById("{$this->id}");
4040
var options = {$options};
41-
var editor = new JSONEditor(container, options);
41+
window['editor_{$this->id}'] = new JSONEditor(container, options);
4242
4343
// set json
4444
var json = {$json};
45-
editor.set(json);
45+
window['editor_{$this->id}'].set(json);
4646
4747
// get json
4848
$('button[type="submit"]').click(function() {
49-
var json = editor.get()
49+
var json = window['editor_{$this->id}'].get()
5050
$('input[id={$this->id}_input]').val(JSON.stringify(json))
5151
})
5252
EOT;

0 commit comments

Comments
 (0)