ViewField - Empty content view

Created on 4 August 2025, 20 days ago

Problem/Motivation

When I use "Viewfield" subfield of custom_field - to render a view it draws it even it is empty (No results behavior).

Normally user would not notice it, but in my case I am using Field Group β†’ module with tabs and tabs are not hidden by default because this subgield tries to render an extra field even it is empty.

Steps to reproduce

Example:
Without Field group:

With field group module:

Proposed resolution

Currently we are using following module Entity Extra Field β†’ and there was the same issue described here " 3469612 πŸ› Hide block/view if No results behavior Active but was recently fixed with patch merge request !33. The result is that Entity extra field won't render view or block and Field group tab is hidden by default so if my project don't have any view information it is not displayed at all.

Does anyone can check that fix for " 3469612 πŸ› Hide block/view if No results behavior Active and possibly use it as starting point to fix also that viewfield subfield issue ?

πŸ’¬ Support request
Status

Active

Version

3.1

Component

Code

Created by

πŸ‡ΈπŸ‡°Slovakia coaston

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @coaston
  • πŸ‡ΊπŸ‡ΈUnited States apmsooner

    I'm not able to reproduce this issue. Every scenario I've tested there is no markup if the view is empty. You seem to have a few other modules in the mix like Entity Extra Field that perhaps is doing contributing? I don't really have an answer for you if I can't reproduce it and I don't use that other module.

  • πŸ‡ΈπŸ‡°Slovakia coaston

    First of all - My bad, I should mention that currently I am using Entity Extra field and would like to replace it and use only your "custom_field" module. That is the reason why I raised this issue.

    Secondly. I am testing on clean drupal 10.5.1 latest version where currently only 2 contrib modules are installed 1.Custom_field and 2.ECA. I have also uninstalled already mentioned "Field Group" module.

    I am quite surprised that you are not able to reproduce the issue because it is quite simple, but here you can find detailed step by step:

    1. Create Content TYPE A (Project)
    2. Create Content TYPE B (Project Inventory)
    -on TYPE B - add field entity reference to Content type A

    3.Create dummy Project (content type A)
    4.Create dummy Inventory with ref to Project.

    Create a View like "Project Inventories" of Type B.
    -Add Relation ship - connect project with inventory (Ref to Project field)
    -Add Title with relationship.
    -Add Contextual filter - ID (with relationship and Provide default value : Content ID from URL)

    Now you should be able to see view only for specific Project ID.

    5- on Content TYPE A - add field > custom_field with subfield viewfield and use that currently created view (Project Inventories)

    6. Now go to our first project edit it and assign that viewfield with that view
    7.You should be able to see our view displayed correctly.

    8.Now create new dummy project our viewfield and visit it.
    9.You should be able to see at least label of our viewfield but also class in browser.

    Of course in Manage display I can disable all labels so I have tried but still it tries to render anything:

    With above steps this you should be able to simply reproduce the issue.
    I have mentioned Entity Extra field because there was exactly the same problem and it was resolved. Now it won't display/render anything in browser!.

    Another step is to install already mentioned Field group module, which uses tabs and if there is no any view rendered, the tab is hidden by default. In some cases our Projects don't have any Inventory at all so our customers would be confused what this tab means and why it is there displayed and empty. Thats why I would like to not see it if there no any inventory assigned to project.

    Entity extra field basically does the same thing as your viewfield ,except it can render also blocks, but I don't use it for blocks, so I would love to uninstall it and use only your viewfield subfield as in my case it does the same.

    Hope it makes sense now.

  • πŸ‡ΊπŸ‡ΈUnited States apmsooner

    There shouldn't be any special rendering functions needed here but views can be finicky about what it considers empty as there's all sorts of rewrite options and some displays react differently. I would probably need to see your config for all this to figure it out. Hit me up in slack if you want. Drupal.org commenting is really poor for attaching anything...

  • πŸ‡ΊπŸ‡ΈUnited States apmsooner
Production build 0.71.5 2024