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.

CommentFileSizeAuthor
#9 1207366-backport.patch742 bytesdawehner
#3 1207366-form-empty.patch736 bytesdawehner

Comments

dawehner’s picture

In 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.

dawehner’s picture

In 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.

dawehner’s picture

Status: Active » Needs review
StatusFileSize
new736 bytes

I 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.

R.Hendel’s picture

Subscribing

R.Hendel’s picture

Status: Needs review » Reviewed & tested by the community

Thx a lot :-)

bojanz’s picture

Status: Reviewed & tested by the community » Needs work

I 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 :)

bojanz’s picture

Status: Needs work » Reviewed & tested by the community

Okay, 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.

dawehner’s picture

Version: 7.x-3.x-dev » 6.x-3.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Thanks for the review. Commited to 7.x-3.x

dawehner’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new742 bytes

Okay here is the backport of this fix.

I really have to think about some phrases on backports.

nagiek’s picture

Hello,

This issue has become unfixed. I still get the empty text, but it is placed within a .views-content class, not .views-empty.

I think this patch should address that?

Status: Needs review » Needs work

The last submitted patch, 1207366-backport.patch, failed testing.

chris matthews’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)

The 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