Details
-
Bug
-
Resolution: Fixed
-
High
-
5.4.1
Description
If you have an attribute of the "layout" datatype and leave it empty, ez_is_field_empty will always return false (implying it's not empty).
A dump of the content will show the following for the layout attribute
["my_layout"]=> array(1) { ["eng-GB"]=> object(eZ\Publish\Core\FieldType\Page\Value)#855 (1) { ["page"]=> object(eZ\Publish\Core\FieldType\Page\Parts\Page)#849 (4) { ["zones":protected]=> array(0) { } ["zonesById":protected]=> array(0) { } ["layout":protected]=> NULL ["attributes"]=> array(0) { } } } }
Steps to reproduce.
- Create a new class and add a "test_me" layout attribute
- Make an override template for that class and add the following code to it
{% if not ez_is_field_empty( content, 'test_me' ) %} <h3>This is not empty</h3> {% endif %}
- Create a content of that class and try to open it in the frontend. You will see the "This is not empty" header displayed.
Note
If you try to render the layout field
{% if not ez_is_field_empty( content, 'test_me' ) %} {{ ez_render_field(content, 'test_me', {'contentViewFullID': content.id}) }} {% endif %}
You will get the following exception
An exception has been thrown during the rendering of a template ("Could not find an ezpage zone definition block for given layout ''") in "EzPublishCoreBundle::content_fields.html.twig".