This occurs only if the value of the field is overwritten, in my case it contains some html tags. Also the option for hiding the values with "0" value stopped working either. This seems as a regression bug.

Comments

dawehner’s picture

Status: Active » Postponed (maintainer needs more info)

Please provide at least some information. You should read http://drupal.org/node/571990

You know a) is broken is wrong because it works for 95% of all the people. If not you would see many people complaining here.

SpaceEater’s picture

Title: Views doesn't respect hide field if empty value option » North Face Jackets
SpaceEater’s picture

Title: North Face Jackets » Views doesn't respect hide field if empty value option
chrislabeard’s picture

I'm having the same problem, views no longer hides the field if its empty and you are using the field rewrite.

Was working fine before updating to 6.x-2.14.

Dimonka’s picture

I have the same problem

creeksideplayers’s picture

I have the same problem. I have "Rewrite the output of this field" checked and "Hide if empty" checked. This successfully hid empty fields in 6.x-2.12, but now I'm seeing the field rewrite value.

Anonymous’s picture

Same problem.

#7 explains it well.

dawehner’s picture

Can't you explain how to reproduce the problem? This would help you because we can fix the issue.

creeksideplayers’s picture

I was able to fix this problem by swapping the first two if statements in render_text() in the file handlers/views_handler_field.inc:

    if ($this->options['hide_empty'] && empty($value) && ($value !== 0 || $this->options['empty_zero'])) {
      return '';
    }

    if (!empty($alter['alter_text']) && $alter['text'] !== '') {
      $tokens = $this->get_render_tokens($alter);
      $value = $this->render_altered($alter, $tokens);
    }
Anonymous’s picture

To reproduce:

1. Make a rewritten field that includes the value of the field. Put some HTML or any text around it.
2. Check "hide when empty"
3. Check the view with records that are not empty and ones that are, or just check it with all empty values for that rewritten field. It shouldn't matter.
4. Views will always render the rewritten portion (ie the text or HTML you added), but the field value itself is not in the rewritten portion (because it's empty)!

Before, it would hide the whole rewritten portion.

Anonymous’s picture

#10 fixed it for me

mwsam’s picture

Title: Views doesn't respect hide field if empty value option » Views doesn't respect hide field if empty value option when using output rewriting

There is a behavior change in latest development version where rewritten output is taken into consideration when determining whether a field value is empty or not. But 3.x also provides an additional option 'Hide rewriting if empty' in the user interface to prevent showing rewritten output if original value is empty. Related issues: #941114: "Hide if empty" not hiding items and #1020540: Add a "Hide Rewriting if field is empty" option.

This change contradicts with Views 6.x-2.12 (and prior versions also?), which by default hides rewritten output if original value is empty.

creeksideplayers’s picture

Title: Views doesn't respect hide field if empty value option when using output rewriting » Views doesn't respect hide field if empty value option

Suppose you have two fields, value_1 and value_2. Let assume value_1 is never empty, but value_2 can be empty. If you have both values, display "value_1 & value_2"; otherwise, just display "value_1". The way I did this was as follows:

  • value_2 - Set "Exclude from display", set "Rewrite the output of this field", and enter " & [value_2]" (without the quotes), set "Hide if empty"
  • value_1 - Set "Rewrite the output of this field" and enter "[value_1][value_2]" (without the quotes)

In views-6.x-2.12, this would show "value_1" if value_2 was empty. In views-6.x-2.14, I now see "value_1 &".

mrhanlon’s picture

Having this problem as well. Reverting to 6.x-2.13 fixed it.

nrackleff’s picture

subscribing

SpaceEater’s picture

Status: Postponed (maintainer needs more info) » Active

To make things clear:

Characters:
Views 6-2.12, Views 6-2.14, An empty field, Div tag, Hide if empty option, User

Act I (also the last one)

User: Hello Views 6-2.12, show me the value of that field, but overwrite it, so I want to see the value surrounded by Div tag.
Hide if empty option: And me! And me! Don't forget about me!
User: Ok. Views 6-2.12, hide the field from me if it is empty.
Views 6-2.12: Here is the result: (nothing being shown)
(silence and then loud applauses)
User: Good job, Views 6-2.12! I know I can rely on you. Now, Views 6-2.14, show us your skill, buddy.
Views 6-2.14 shows Div tag. Timid cheers from the audience. Hide if empty option starts crying
User: You definitely wrong, Views 6-2.14. You should show us the same nothing as previous fellow!
Views 6-2.14: (sadly) Ok.

The end :-)

Please tell us if you need more information to fix this issue.

dawehner’s picture

Status: Active » Fixed

See #1331032: Empty rewritten fields are not hidden anymore

You can configure views now exactly how you need it.

creeksideplayers’s picture

I checked the issue that you referenced, but I don't see a patch that fixes this issue.

bbc’s picture

Thanks hsvmda. Your fix (#10) did the trick for me.

dawehner’s picture

@hsvmda

Yeah this is quite a major bug so it should be fixed in the next views version. Just commited the patch from 6.x-3.x but this will be an exception, because 6.x-2.x is in a really stable status.

creeksideplayers’s picture

@dereine: Yes, I read that. Does that mean you are not going to be fixing this in 6.x-2.x?

dawehner’s picture

No... this is already commited to views 2.x-dev.

creeksideplayers’s picture

Thanks, I managed to find it (http://ftp.drupal.org/files/projects/views-6.x-2.x-dev.tar.gz) even though there was no link on the views project page. Also, it would have been nice if the update could have set the "Do not rewrite if empty" automatically when "Hide if empty" and "Rewrite the output of this field" are both set. If was rather painful having to go through all my views and figure out which fields needed this set.

royerd’s picture

Why is there no link to the DEV version in the list of other versions?

Dev version linked above works.

merlinofchaos’s picture

If you need the -dev version, it's available under 'list all releases'. Because Views has a lot of releases, it's true that you have to go to the last page. But it's there, and it's findable. I'm not inclined to do anything more simply because, a mere 4 days after the release of 2.14 (2 of which are weekend days, no less), you are not satisfied. Have you no patience? Are we, the volunteer maintainers to Views, to be at your beck and call for your whims?

The -dev version of the 2.x branch isn't listed because I only want people who are prepared to deal with the consequences of a -dev version to download it. Anyone who can't be bothered to click on the list of all releases and find it is clearly in the category of not prepared to deal with the consequences of running a -dev version, in my opinion.

Shai’s picture

@merlinofchaos,

I'm a patient and huge fan of Views, you and your Views team.

And unlike @royerd, I did not request better documentation and/or a dev link here, in a fixed issue. Instead, yesterday I posted an issue as per protocol:

#1333442: Better Documentation Urgent for Views Substitution Problem

But since you and @royerd are following this issue and not that one, I'll respond here, though it is technically out of place. I understand and apologize.

Here is the key point: many sites that have been running the 6.12 stable release, and who, by general policy, only run stable releases, must now (due to this issue and also #1330716: Views substitutions broken after db_safe() update), run the latest development release of 6.x. It's not about devs playing risky by using development releases, but rather requiring an alternative because updating to the latest stable release has broken their site.

An alternative to listing the 6.x-2.x-dev in the releases section is to put a short note on the project page describing some of the problems with 6.14.

Also, for people who haven't updated yet from 6.12, it would be helpful to recommend on the project page that folks update only to 6.13 until 6.15 comes out (that's presuming that the problems in these two issues occur in 6.14 and not 6.13, correct me if I'm wrong).

There are over 20,000 D6 sites running the Flag module which was broken by 6.14. The total number of sites potentially affected when people update from Views 6.12 is a lot more. We don't want to discourage people from making security updates. I always read the project page before updating. A couple of sentences on the project page could save people a great amount of time and heartache.

With huge admiration, appreciation, and respect,

Shai Gluskin

SpaceEater’s picture

First of all let me say thank you to all views team members. You are doing a great job for all of us.

The problem with such bugs can be easily solved if we have a note on views module page "Known problems". More radical suggestion is to change the release cycle, so we can have 6.x-2.14.2 release with small fixes, but in my opinion this question lays far beyond this thread discussion.

Status: Fixed » Closed (fixed)

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

calefilm’s picture

Version: 6.x-2.14 » 6.x-3.x-dev
calefilm’s picture

Title: Views doesn't respect hide field if empty value option » Empty text not working when rewrite output is selected
Version: 6.x-3.x-dev » 6.x-2.14
calefilm’s picture

Version: 6.x-2.14 » 6.x-3.x-dev
Status: Closed (fixed) » Active

I just upgraded from 2.12 to 2.16 and wham! Empty Text is not working like in 2.12. Several of my views that I was using where I was applying images to the Empty Text box now don't come up. I don't understand the newly created rewrite checkbox -- which I thought was the original issue but as the original poster pointed out it has to do with the fact that "This occurs only if the value of the field is overwritten"

I first upgraded to 2.16 Problem persists.
Then I upgraded to 6.x-2.14 but problem persists.

Coming here I found people had gone from 2.14 to 2.x dev. Can one of you tell me what I should do? I hate to refer back to 2.12 but that seems like a good option at this time. Am I better off going to 2.x dev or going with the fix in #10 -- but that's for 2.14.

UPDATE:

I gave 2.x dev a whirl for about 5 minutes but it seemed to be doing the same thing.. I'm just going back to 2.12. Hopefully that's okay and safe. I'm too new to be messing around with dev stuff.

SpaceEater’s picture

Version: 6.x-3.x-dev » 6.x-2.14
Status: Active » Closed (fixed)

This bug was introduced in 2.14 and fixed in later release. Check new "Do not rewrite if empty" field option, I think that is was you are looking for, if not may be you should open new support request issue. Also, 2.12 has critical security issue, so I suggest you not to use it anymore.

calefilm’s picture

Thanks Ostasevich. I checked that multiple times, even reconfiguring types of output but this made no difference. I'm using 2.13 [works] instead of 2.12. I'll update this post again if I can figure out what my problem is.. since nobody else seems to have this same issue anymore.

naoliva’s picture

Version: 6.x-2.14 » 7.x-3.1
Assigned: Unassigned » naoliva
Priority: Major » Normal
Status: Closed (fixed) » Active

"Hide rewriting results if empty" is not working for me.
I've been using Views 7.x-3.1 and creating a Table of Field_Collection items.
Rewriting is made by javascript bellow:

<script type="text/javascript"><!--
var i = "[field_cafe]";
document.write(i.replace("Not available", "" );
//-->
</script>

[field_cafe] is token,
I can view the table with all the other fields filled up but also the label of field_cafe and blank values.

HTML Source-Code

... <th class="views-field views-field-field-cafe" >
            Café          </th> ...
... <td class="views-field views-field-field-cafe views-align-left" >
                      </td> ...

Please let me know everybody if I committed some clear mistake.

dawehner’s picture

Version: 7.x-3.1 » 6.x-2.14
Assigned: naoliva » Unassigned
Priority: Normal » Major
Status: Active » Closed (fixed)

Well javascript is simply not allowed in the rewrite field, update status because this seemed to be some kind of hijacking of the issue.