<div class="col-xs-12 col-sm-12 col-md-12">
<div class="form-group">
<strong>{FIELD_DISPLAY_NAME}:</strong>
<textarea
class="json_text"
name="{FIELD_MACHINE_NAME}"
id="jsontext_{FIELD_MACHINE_NAME}"
>{!! is_string({MODEL_VARIABLE}) ? {MODEL_VARIABLE} : json_encode({MODEL_VARIABLE} ?? new stdClass()) !!}</textarea>
<div id="jsoneditor_{FIELD_MACHINE_NAME}" class="json_editor"></div>
<script>
(function(uid){
container = document.getElementById("jsoneditor_" + uid)
options = {
modes: ["code", "tree"],
onChangeText: function(jsonString){
document.getElementById("jsontext_" + uid).value = jsonString;
}
}
editor = new JSONEditor(this.container, this.options)
initial = {!! is_string({MODEL_VARIABLE}) ? {MODEL_VARIABLE} : json_encode({MODEL_VARIABLE} ?? new stdClass()) !!}
editor.set(initial)
})("{FIELD_MACHINE_NAME}");
</script>
</div>
</div>
|