craft-dynamic-fields icon indicating copy to clipboard operation
craft-dynamic-fields copied to clipboard

Dynamic Field output in twig breaks Live Preview

Open Tim-Wils opened this issue 6 years ago • 0 comments

Outputting the field in twig breaks the Live Preview functionality and gives an error. The problem is that the field needs to be json_encoded in the Live Preview.

To workaround this problem, this is a fix on the twig-side:

{% if craft.app.request.isLivePreview %} {{ myDynamicField|json_encode}} {% else %} {{ myDynamicField }} {% endif %}

Tim-Wils avatar Jan 25 '19 10:01 Tim-Wils