Hello,

The field is displayed even if it's content is empty ??? How can I hide it if there's no output value?

Thank you.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

RedRat’s picture

Component: Documentation » Code
Category: support » bug

There is a semi-solution for this problem: http://drupal.org/node/1349904

But if you don't want to store field values in the DB, your field will be always visible, even if it empty. I am sure it's a bug in the code, but the module is almost not maintained now. :-(

rjacobs’s picture

Title: Hide empty field » Hide field when output is empty (and DB is not used for storage)
Version: 7.x-1.0-beta1 » 7.x-1.x-dev
Status: Active » Needs review
FileSize
1.82 KB

It would seem that this is not a problem for fields stored in the DB because they are tested as empty/non-empty each time the field is saved (via computed_field_field_is_empty()). If nothing is saved, then Drupal knows there is nothing to display.

Fields that don't use the DB for storage don't receive this "is_empty" check. However, I think it would be possible to implement a similar check at display time within computed_field_field_formatter_view(), which is what the attached patch attempts to do.

Perhaps others could test this out.

RedRat’s picture

I will try your patch as soon as return from vacation.

AaronBauman’s picture

tested #2, works as described
let's get one more review for RTBC

Anybody’s picture

Issue summary: View changes

I can confirm that

  1. This is still an essential issue
  2. The patch works great
  3. Is now set RTBC
  4. I'd be happy to see this in the next .dev release :)

Thank you very much for the great work!

AaronBauman’s picture

Status: Needs review » Reviewed & tested by the community
Anybody’s picture

=D Thanks. Forgot to select. Sorry xD

colan’s picture

Status: Reviewed & tested by the community » Needs work

Thanks! Looks great. I'll happily commit this once the extra whitespace is removed from line 348.

Anybody’s picture

Status: Needs work » Needs review
FileSize
1.82 KB
Anybody’s picture

@colan: Please review and set RTBC again if it's ok!

colan’s picture

The corresponding issue for values stored in the DB is #1440234: Zeroes in string types are assumed to be empty (DB used for storage). Please review that one if you can as nobody's look at it yet.

@Anybody: No, sorry, I can still see whitespace there with Dreditor.

colan’s picture

Status: Needs review » Needs work
rjacobs’s picture

Looks like this was one of my patches from long ago. Dunno how that whitespace got in there. I double-checked the the patch still applies cleanly, and though it does there is some offset. Because of this I went ahead with a re-roll (that also stripped white space).

  • colan committed 5f90332 on 7.x-1.x authored by rjacobs
    Issue #1928178 by rjacobs: Hide empty fields that do not use DB for...
colan’s picture

Status: Needs review » Fixed

Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.