Jump to:

23550 Posts in 19336 Topics by 2890 members

General Questions

SilverStripe Forums » General Questions » Rego Form for a Calendar Event

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 931 Views
  • ccburns
    Avatar
    Community Member
    74 Posts

    Rego Form for a Calendar Event Link to this post

    Hi All,

    I have searched through the forum for an example of a registration form for a calendar event, but I haven't found any. I almost have things working, except one little sticking point.

    Okay I have extended the CalendarEvent to create a Workshop. At the bottom of the page I want a registration form. I can get the form to display without problem with the following code.

    When I submit the form I get this error

    Fatal error: Class 'Fieldset' not found in /Library/WebServer/Documents/lighthouseresources/httpdocs/mysite/code/Workshop.php on line 35

    Any suggestions why this would happen. If I replace the $fields variable with $fields = singleton('Member')->getCMSFields(); it submits fine (although I don't want to use the member class just using it to try and work out what is going on...

    class Workshop_Controller extends CalendarEvent_Controller {

       function Form() {
          $fields = new Fieldset (
             new TextField('Course', 'Course', $this->Title),
             new DateField('CourseDate', 'Course Date'),
             new TextField('YourName', 'Your Name'),
             new TextField('Organisation', 'Organisation'),
             new TextField('PostalAddress', 'Postal Address'),
             new TextField('Suburb', 'Suburb'),
             new TextField('Postcode', 'Postcode'),
             new TextField('City', 'City'),
             new EmailField('Email', 'Email'),
             new TextField('PhoneBusinessHours', 'Phone (Business Hours)'),
             new TextField('PhoneMobile', 'Mobile Phone'),
             new TextareaField('SpecialRequirements', 'Dietary or Special Requirements'),
             new CompositeField(new OptionsetField('Payment', 'Payment', array("InvoiceMe" => "Invoice Me", "InvoiceMyOrganisation" => "Invoice My Organisation"))),
             new CompositeField(new CheckboxField('ReadTermsAndConditions', "I have read and accept the conditions outlined in the <a href=\"/cancellation-policy/\" title=\"Cancellation Policy\">Our Cancellation Policy</a>"))
          );
          $actions = new FieldSet(
             new FormAction('doSubmitJob', 'Submit')
          );
          $validator = new RequiredFields(
             'FirstName',
             'Surname'
          );
          $form = new Form(
             $this,
             'Form',
             $fields,
             $actions,
             $validator
          );
          return $form;
       }
       
       function doSubmitJob($data, $form) {
          // Do something here like send an email
          //Set data
          $From = "for@emailadress.com";
          $To = "to@emailaddress.com";
          $Subject = "Workshop Registration";
          $email = new Email($From, $To, $Subject);
          //set template
          $email->setTemplate('RegistrationFormEmail');
          //populate template
          $email->populateTemplate($data);
          //send mail
          $email->send();
          //return to submitted message
          $form->sessionMessage(
    'Form successfully submitted',
    'good'
    );
          Director::redirectBack();
          return;
       }

  • ccburns
    Avatar
    Community Member
    74 Posts

    Re: Rego Form for a Calendar Event Link to this post

    Anyone willing/able to help. I imagine this is something that a thousand people have done before me and isn't that difficult. I am either go about it the wrong way or am just calling a wrong function or something.

    Any help would really be appreciated.

    Cheers,
    Colin

  • Juanitou
    Avatar
    Community Member
    323 Posts

    Re: Rego Form for a Calendar Event Link to this post

    Hi Colin,

    Try writing FieldSet correctly on that second line: it reads Fieldset.

    Hope it helps,
    Juan

  • ccburns
    Avatar
    Community Member
    74 Posts

    Re: Rego Form for a Calendar Event Link to this post

    Firstly sorry for being a retard and secondly thanks for solving the problem.

    Quick question. That particular method is used to generate the form in the first place and it doesn't fail then. It only failed in the second instance on submission? Seems a bit strange or am I AGAIN missing something very simple.

    Thanks again,
    Colin

  • Juanitou
    Avatar
    Community Member
    323 Posts

    Re: Rego Form for a Calendar Event Link to this post

    You’re not alone in Retardland: I asked myself the same question about a form being correctly shown despite the error in spelling, then failing on submission. The trace of the error should explain it.

  • ccburns
    Avatar
    Community Member
    74 Posts

    Re: Rego Form for a Calendar Event Link to this post

    Thanks again for the help. I will definitely take another look at the error trace and see what is going on.

    Cheers,
    Colin

    931 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.