REST views: remove "Hide If Empty" option (Field Level)

Created on 9 June 2017, about 7 years ago
Updated 15 March 2023, over 1 year ago

Issue summary updated as of comment #44

Problem/Motivation

When creating a REST view with fields. When checking "hide if empty" the field is still appearing in the feed.

Steps to reproduce

  1. Create some dummy nodes with an empty body
  2. Create a REST view
  3. Showing fields add body
  4. In the field settings check "hide if empty"
  5. In the preview see that the body field is still there.

Proposed resolution

If the field is empty and "hide if empty" is checked I would expect the field to not appear in the feed.

Remaining tasks

Code review

User interface changes

API changes

This could affect users who are having to put checks into their feeds for empty values - Maybe

Data model changes

Release notes snippet

The option in REST views to "Hide If Empty" was not being respected and the field items were always shown in the rest view regardless of the setting. To keep backwards compatibility it was chosen to simply remove the "Hide If Empty" option. This removal has no effect on existing sites that might have set the option since it was disregarded.

Original report by Anishnirmal

Hi,

I have created view with rest export and I configured field for that view. For Fields under "No Result Behavior", I have enabled "hide if empty" option to hide the field which has no value. But in view result, that field didn't get hide.

🐛 Bug report
Status

Needs work

Version

10.1

Component
REST 

Last updated 6 days ago

Created by

🇮🇳India Anishnirmal

Live updates comments and jobs are added and updated live.
  • VDC

    Related to the Views in Drupal Core initiative.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇫🇮Finland iamfredrik

    You may remove the option by default for backwards compatibility, but please make the option to hide fields into a setting. My use case is that I have a bunch of different content types with different fields. I use the grouping patch from here https://www.drupal.org/project/drupal/issues/3251937 to group the fields by content type. In this case it doesn't make sense to show empty fields for those content types that don't have the fields.

  • 🇪🇨Ecuador jwilson3

    I think this issue still needs an IS update. The title of the issue has been updated to reflect that the approach in the patches is to remove the "Hide if empty" option, however the Proposed resolution is still talking about the expected behavior when the option is checked, which is the inverse of removing the option entirely.

Production build 0.71.5 2024