Currently there is a problem with views forms and empty results.
In general it should be supported to render the empty text if there is no result but it doesn't work in general at the moment,
because:
$vars['rows'] = drupal_render($form);
and
<?php if ($rows): ?>
<div class="view-content">
<?php print $rows; ?>
</div>
<?php elseif ($empty): ?>
<div class="view-empty">
<?php print $empty; ?>
</div>
<?php endif; ?>
The form itself is probably never empty, so rendering is wrong.
One thing which could be done is to check for $empty in template_preprocess_views_view and only then render $vars['rows']
This would not allow to control this behaviour by the form plugin, but is this really required?
Assign to bojanz to get some feedback.
OT: Added a views form component.
Comments
Comment #1
dawehnerIn general this have to be handled by the form plugin, because just for example views bulk operations should display the empty text above it's buttons.
Comment #2
dawehnerIn general this have to be handled by the form plugin, because just for example views bulk operations should display the empty text above it's buttons.
Comment #3
dawehnerI can't say how much i hate things like this.
Once you addicted with it you can't do anything unless you fix this issue.
Here is a real patch for this issue. So the plugin doesn't have to handle anything but could if it's really needed.
Comment #4
R.Hendel commentedSubscribing
Comment #5
R.Hendel commentedThx a lot :-)
Comment #6
bojanz commentedI don't think we should call Views Form at all if the view is empty.
I mean, the "empty" area handler could handle views_form() like the header / footer line items, but that's a feature request.
In this case, we just need to bail if it's empty.
if (!empty($vars['rows']) && views_view_has_form_elements($view)) {
How does that sound?
And yay for the new component :)
Comment #7
bojanz commentedOkay, wait, we still want the header / footer area handlers to fire. They can decide for themselves if the view is empty and whether they should do anything.
Let's go with the patch.
Comment #8
dawehnerThanks for the review. Commited to 7.x-3.x
Comment #9
dawehnerOkay here is the backport of this fix.
I really have to think about some phrases on backports.
Comment #10
nagiek commentedHello,
This issue has become unfixed. I still get the empty text, but it is placed within a
.views-contentclass, not.views-empty.I think this patch should address that?
Comment #12
chris matthews commentedThe Drupal 6 branch is no longer supported, please check with the D6LTS project if you need further support. For more information as to why this issue was closed, please see issue #3030347: Plan to clean process issue queue