That was once fixed in D7 #1432078: If view is empty "Save" button is still visible but not ported to D8+.

CommentFileSizeAuthor
#2 weight-empty-view-3226688-2.patch508 byteschi

Comments

Chi created an issue. See original summary.

chi’s picture

StatusFileSize
new508 bytes
chi’s picture

Status: Active » Needs review

I am not sure if this is the best way to fix this. We could probably check how other contrib modules handle this.

darvanen’s picture

This removes all actions associated with a view, which may remove buttons provided by other (contrib/custom) modules that are still useful when there are no results. I don't know of any, but implementing this would be a case of the module reaching beyond the boundaries of its own logic.

I suggest that instead we open a core issue requesting that this part of ViewsFormMainForm::buildForm pays attention to a return value to determine if a form is actually required in the circumstances:

      // If the field provides a views form, allow it to modify the $form array.
      $has_form = FALSE;
      if (method_exists($field, 'viewsForm')) {
        $field->viewsForm($form, $form_state);
        $has_form = TRUE;
      }

Thoughts?

anybody’s picture

Status: Needs review » Needs work

Agree with #4. The #access=FALSE should only apply on the button from weight module.