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

Thank you.


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
new1.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