Hi,
So I limitted the submissions of users to 1 per day.

After they submit the from in the block, the form hides but the block title and block body frame still remain. I even tried to give <none> title to webform block, but the small themed empty block body still remains even though there's nothing to display at all.

Thanks for your time.

CommentFileSizeAuthor
#2 webform_empty_block-d7.patch502 bytesquicksketch
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

trigdog’s picture

I was also wondering this. I have my form block on the user's profile page and it just clutters up their page once they have submitted the form since they can only submit the form once. If the following code is added to the webform_block_view hook in webform.module (I added it after the node access check) it seems to hide the block if the user submission limit has been reached. However, I am not sure if this is the correct way to do this or if the cache check is needed since it is a block. Hopefully someone else with more knowledge of the webform module can tell us if this is possible.

$user_limit_exceeded = FALSE;

// Check if this page is cached or not.
$cached = $user->uid == 0 && (variable_get('cache', 0) || drupal_page_is_cacheable() === FALSE);

// Check if the user can add another submission.
if ($node->webform['submit_limit'] != -1) { // -1: Submissions are never throttled.
module_load_include('inc', 'webform', 'includes/webform.submissions');

  // Disable the form if the limit is exceeded and page cache is not active.
  if (($user_limit_exceeded = _webform_submission_user_limit_check($node)) && !$cached) {
    return;
  }
}

Edit: Looking at webform_submission_user_limit_check, if webform_submissions has a lot of entries, this might decrease performance on pages that the block is loading even if it isn't being displayed since it has to do this check every time.

quicksketch’s picture

Version: 7.x-3.9 » 7.x-3.15
Status: Active » Fixed
FileSize
502 bytes

Thanks, I've confirmed this problem in the latest code. Looks like it's because we're passing back a renderable array which contains a lot of content. However when the renderable is actually run, it doesn't return anything. To prevent the block from showing up, we can build the content sooner which lets block module know that the block is empty. I've committed this patch which fixes the problem, which seems to only affect D7.

quicksketch’s picture

Title: The block won't hide when the subimssions are limitted » The block won't hide when the submissions are limited
trigdog’s picture

Thank you :) Got it working with your patch!

Status: Fixed » Closed (fixed)

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