Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-24106

ez_is_field_empty does not work for a Page field

    XMLWordPrintable

    Details

      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.

      1. Create a new class and add a "test_me" layout attribute
      2. 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 %}
        
      3. 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".

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              eduardo.fernandes-obsolete@ez.no Eduardo Fernandes (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours, 45 minutes
                2h 45m