craft-dynamic-fields
craft-dynamic-fields copied to clipboard
Dynamic Field output in twig breaks Live Preview
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 %}