Skip to content

Commit

Permalink
[SonataExtraBundle] Json viewer allow to pass options to configure it
Browse files Browse the repository at this point in the history
  • Loading branch information
mpoiriert committed Jul 4, 2024
1 parent 60faaa7 commit 807d82a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
$(function () {
$('div.json-viewer').each(function () {
$(this).jsonViewer($(this).data('json'), {withLinks: false});
$(this).jsonViewer(
$(this).data('json'),
Object.assign(
{},
{withLinks: false},
$(this).data('options') || {},
)
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@
{% if not value %}
<i>No data</i>
{% endif %}
<div class="json-viewer" data-json='{{ value|json_encode()|e('html_attr') }}'></div>
<div class="json-viewer"
data-json='{{ value|json_encode()|e('html_attr') }}'
data-options='{{ field_description.options.view_options|default({})|json_encode()|e('html_attr') }}'
></div>
{% endblock %}

0 comments on commit 807d82a

Please sign in to comment.