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.

Form Questions /

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


Reply


2 Posts   461 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, 5513 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;
}
}