Table fields with the integer value zero are not displayed.
Instead the field is made empty.

The problem lays in the function template_preprocess_views_view_table.
In that function is the variable "field_output" checked to see if it is not empty.
The variable should be checked if it is set.

Now
if (!empty($field_output) && empty($column_reference['content'])) {

Should be:
if (isset($field_output) && empty($column_reference['content'])) {

file: core/modules/views/views.theme.inc

Comments

daffie’s picture

Status: Active » Needs review
StatusFileSize
new0 bytes
jeroent’s picture

Status: Needs review » Needs work

Patch is empty.

daffie’s picture

Oeps! Sorry, new try :)

daffie’s picture

Status: Needs work » Needs review
longwave’s picture

This seems like something that should have a test.

dawehner’s picture

Table fields with the value zero are not displayed.
Instead the field is made empty.

Fields do have a setting to be considered empty, when there is a "0" displayed.
In addition tables have a setting to hide a column, if all fields are empty. We need to be sure that this patch does not break that feature, because it is really kind of helpful.

daffie’s picture

Title: Table fields with the value zero are not displayed. » Table fields with the integer value zero are not displayed.
Issue summary: View changes
daffie’s picture

I have added a test to the patch. This is the first time I wrote a test for PHPUnit. So please take a good look at it.

In addition tables have a setting to hide a column, if all fields are empty. We need to be sure that this patch does not break that feature, because it is really kind of helpful.

@dawehner: Do you know if this functionality is tested in views?

Status: Needs review » Needs work

The last submitted patch, 8: field-with-zero-value-is-not-displayed-2171497-8.patch, failed testing.

daffie’s picture

The previous one work in my local machine. Does the testrobot have php 5.4?

longwave’s picture

daffie’s picture

@longwave: Thanks for the info.

longwave’s picture

Status: Needs work » Needs review
dalearyous’s picture

so with this patch, views table will not consider a field empty if its value is 0?

jhedstrom’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll
lokapujya’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new2.07 KB

Reroll, while I test this issue.

jhedstrom’s picture

Status: Needs review » Closed (duplicate)

This is a duplicate of #2244507: template_preprocess_views_view_table ignores zero values, which also has a test for the 'treat 0 as empty' setting. Sorry I didn't realize that when marking as needs reroll.

jhedstrom’s picture

Some of the logic from this test could perhaps be merged into the test over at #2244507: template_preprocess_views_view_table ignores zero values since the approach is slightly different.

Status: Closed (duplicate) » Needs work

The last submitted patch, 16: 2171497-16.patch, failed testing.

idebr’s picture

Status: Needs work » Closed (duplicate)
Related issues: +#2244507: template_preprocess_views_view_table ignores zero values

Closed again per #17