I always like to have empty CCK fields completely disappear from the node-viewing page - it's all nice to have a bunch of fields for all possible things, but never show a lame page with most fields blank. I even creatd a patch previously to do this.

As of upgrading to 5.x-1.5 now, I see that this is already implemented - that's great. But there's a problem: The check for the field being empty is done AFTER all the input-format filters, so the empty fields are (in my config) never detected as being empty, because of all kinds of empty DIV's, BR's with float-clearing classes, HTML comments with filter version etc. etc. Simply the filters sometimes add invissible markup-mess even to empty fields.

So, I think that the check for empty fields should be done BEFORE filtering (alternatively not calling the filter at all, if empty).

I have a sort of patch working, but it's senseless here, as it's just a workaround with hacked filtering-module.

It would be also nice, to have this behaviour (hiding empty fields) configurable, to avoid confusion of other users, who don't want it.

Comments

yched’s picture

Status: Active » Closed (works as designed)

I'm tempted to mark as 'by design', for I don't think this can work that way.
Before we can decide if there is something to display or not, we do have to let the formatters get a chance to run;

Some formatters for some field types might decide to display something for 'empty' values.
Some formatters (is it imagefield ?) even leave the actual output to theme functions, meaning the theme / themer might override the default behaviour and treat empty values the way they like.

Besides, there is not really any generic concept of 'empty' value, this might depend on the field type : NULL, empty string, 0... ?
The only reliable criteria we have is 'is the output string empty' ?

I think the best approach is to try and see why you filters return 'almost but not empty' strings ?

About the setting to turn 'hiding empty fields' on / off - i remember we thought about it when the field display part was reworked a few months ago, and decided it would mainly add confusion to the cck settings pages, that are crowded enough already. This might be reconsidered of course, but in about 6 months time, you're the only one who actually pointed that :-)
For the time being, this behaviour is coded in a theme function, so it can easily be overrided.

JirkaRybka’s picture

Okay, I'll stick with my custom patching on each upgrade, then. No big deal about that, I just thought it might be good to solve in a more clean way, if possible. I meant textfields (the only ones for text-input filters, in my case at least), where the "empty string" condition is no problem.

BTW, the filtering module I speak of is Texy!, the pseudo-markup formatter. Any empty field after applying Texy looks like this:
<p></p><br class="clear" /><!-- By Texy! 2 --> And I can't do anything about it cleanly. (I have a patch to detect empty fields myself, and avoid the main filtering function at all, but that's just a quick hack.)

yched’s picture

Status: Closed (works as designed) » Active

Sounds like a (non-minor) bug in Texy ...
But, well, maybe you're right, the specific formatter for text fields could check if the value is empty - could possibly even trim the thing first...

Setting back to active :-)

catch’s picture

http://drupal.org/node/129908 was duplicate. There's a few issues related to this this I think.

http://drupal.org/node/101050 is related but since it's views specific I'll leave both open.

catch’s picture

Title: Invisibility of empty fields needs to improve » Empty field handling
Version: 5.x-1.5 » 6.x-1.x-dev

http://drupal.org/node/57228 is pretty much a duplicate as well.

deekayen’s picture

@JirkaRybka: I'm going to have to do something about this issue on one of my projects. If you could dig up that old patch and post it here, there are duplicate issues pointing here where I'm sure people would find it interesting.

cornmuffin’s picture

I had fieldgroups which each display nodereferrers of a specific content type. Since these fieldgroups only contain nodereferrer fields they should not be displayed in the node edit form.

JirkaRybka’s picture

My old patch (still running on the live site) was against the Texy! module, to detect empty input and avoid the call to the formatter itself in that case, preserving the emptiness... Nothing closely bound to CCK, so I don't think it belongs here. ;)

deekayen’s picture

Change the status on this issue based on http://drupal.org/node/277101 ?

JirkaRybka’s picture

Status: Active » Fixed

I have no problems with this anymore, so I assume it's fixed now.

(Cleaning outdated issues in my personal queue... Feel free to re-open if needed!)

Status: Fixed » Closed (fixed)

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

intuited’s picture

Version: 6.x-1.x-dev » 6.x-2.5
Status: Closed (fixed) » Active

If a field group just contains computed fields, the group is displayed but is empty. This seems to me a bug, though maybe one with computed field rather than with the field group.

intuited’s picture

I'm feeling like it was a mistake to file this here, since it does seem to be a problem with computed field and not CCK fieldgroups.

I've filed a bug on that project: #616542: fieldgroups which only contain computed fields are displayed (and empty) in node edit forms.

markus_petrux’s picture

Status: Active » Closed (fixed)

This is not related to CCK. Please, also see #349548: Conditional result for hook_content_is_empty()