It would be nice to be able to prevent further submissions to a webform. It would be useful in a situation, where some data needs to be collected only fixed number of times or until a certain deadline.

Possible options:

  • Manual disabling of a webform
  • Predefined date/time (server-side)
  • Predefined number of answers
  • Soft limits (send an e-mail when time/number of answers reached, possibly with some stats)

Comments

quicksketch’s picture

Is the requirement for this more complicated than just unpublishing the node? That way it is still accessible to administrators but hidden from normal users. Several modules already exist to publish/unpublish on certain conditions or dates.

abaryudin’s picture

No, it would be more useful if the form (at least, the text) stayed there, but the form would be disabled and replaced with some "No more submissions" messages. This is better than unpublishing, since I don't want users to see a "Access denied" message.

abaryudin’s picture

To emphasize the importance of limited submission, have a look at the current development version of the sign-up module - it has an option to limit the number of subscriptions.

quicksketch’s picture

Status: Active » Closed (duplicate)

We'll likely be implementing a sort of access control for webform submissions at http://drupal.org/node/239343. By unchecking all roles that are allowed to submit a particular webform, it effectively disables further form submissions. Once finished you could effectively limit submissions with additional processing code such as this:

$limit = 100;
$submissions = webform_get_submissions($node);
if (count($submissions) >= $limit) {
  $node->webform['roles'] = array();
  node_save($node);
}

Marking as duplicate, let's follow the progress of the other issue.

benstallings’s picture

Version: » 6.x-3.0-beta2
Component: Code » Documentation

Even if unpublishing the node is acceptable, doing so doesn't disable the form from submission. That is, if someone loads the form in their browser while it's published, sits on it for a few minutes or hours, and then submits it, the submission is accepted even if the node has been unpublished in the meantime. This can be problematic for some of us!

Using the following code for Additional Validation solves the problem:

# Don't allow form submission if the node is unpublished.
if ($node->status == 0) {
  form_set_error('', t('The deadline for submitting this form has already passed.  Sorry!'));
}
quicksketch’s picture

That is, if someone loads the form in their browser while it's published, sits on it for a few minutes or hours, and then submits it, the submission is accepted even if the node has been unpublished in the meantime. This can be problematic for some of us!

This problem has been corrected in #376574: Page cache interferes with submit limit for anonymous users.