Jump to:

2012 Posts in 1438 Topics by 621 members

Form Questions

SilverStripe Forums » Form Questions » Is there any way to limit the number of submissions on a form

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

Page: 1
Go to End
Author Topic: 421 Views
  • Medbury
    Avatar
    Community Member
    1 Post

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

    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.

  • Willr
    Avatar
    Forum Moderator
    5511 Posts

    Re: Is there any way to limit the number of submissions on a form Link to this post

    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;
    }
    }

    421 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.