Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Form Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Is there any way to limit the number of submissions on a form


Go to End


2 Posts   1277 Views

Avatar
Medbury

Community Member, 1 Post

20 June 2013 at 12:16pm

I am relatively new to Silverstripe with our new website launching only a couple of months ago.

We have an event coming up and using the forms module I have created a ticket order form. It is for a school event and I was wondering if there any way to limit the number submissions based on the house the child belongs to. Basically wanting that when a house hits 70 ticket requests it won't allow any more?

Many thanks in advance for any help and advice you may be able to give me.

Avatar
Willr

Forum Moderator, 5523 Posts

22 June 2013 at 7:36pm

Nothing built into the module. Though you could quite easily add that functionality to your own site. Create a subclass of UserDefinedForm for your EventPage and customize the Form method to check submissions before outputting the form.

<?php

class CustomUserForm extends UserDefinedForm {

}

class CustomUserForm_Controller extends UserDefinedForm_Controller {

public function Form() {
$form = parent::Form();

if($this->Submissions()->Count() > 70) {
return false; // some message to the user in the template
}

return $form;
}
}