I have recently updated to Views 2.16 and have encountered an issue with some numeric fields in my view.

I have a field that should just display a number, since updating if the field contains a 0 the 0 is not displayed.

i.e. "Our Score: " rather than "Our Score: 0"

As a work around one one view I have entered 0 in the "Empty text" box and ticked treat 0 as empty (so it replaces the 0 with a 0).

This doesn't work on another view for the same data where I want to hide the entire text (label and value) as I have the "Hide if empty" ticked.

CommentFileSizeAuthor
#7 zero-handling-correction.patch3.19 KBbarry_fisher

Comments

tigszero’s picture

I have this problem too after updating to Views 2.16.

tigszero’s picture

I've found that in the field configuration page, the 'Do not rewrite if empty' is checked by default. Not sure if the option was there before; or if it was, if it was checked by default before. Unchecking it solves the problem for my case. (In fact, I edited line 173 of views_handler_field.inc, changing TRUE to FALSE.)

What happened with my site are:

(1) If checked by default, non-rewritten 'zero' integer becomes blank. ('Count the number 0 as empty' formerly unchecked)
(2) If unchecked by default, any rewritten empty content is not hidden. ('Hide if empty' formerly checked)

If the option has just been introduced, I think leaving it checked by default is better. The bug seems to be that a 'zero'-integer field content is treated as empty even though 'Count the number 0 as empty' is unchecked. I don't know much PHP. Do you think this bug has something to do with $this->original_value and line 534 of views_handler_field.inc?

tigszero’s picture

David Lesieur’s picture

Status: Active » Closed (duplicate)
David Lesieur’s picture

Status: Closed (duplicate) » Active

... or maybe not. The original post did not mention if rewriting was involved.

jebbench’s picture

No rewriting involved.

If somebody is willing to port the patch from #1433596 to the 6.x-2.x branch I'm quite happy to apply it and see if helps.

barry_fisher’s picture

StatusFileSize
new3.19 KB

I had this issue showing up in views-6.x-2.16. I've attached a port of the patch in #1433596

I've tested this and it works in my case. However I haven't patched any of the tests to this version, so can only say that it worked for me by manual testing/observing. Some of the logic is slightly different to the ported version so improvements welcome!

mustanggb’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)