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.

General Questions /

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

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

Rego Form for a Calendar Event


Go to End


6 Posts   1423 Views

Avatar
ccburns

Community Member, 79 Posts

3 November 2009 at 6:11pm

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

Avatar
ccburns

Community Member, 79 Posts

4 November 2009 at 5:26pm

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

Avatar
Juanitou

Community Member, 323 Posts

4 November 2009 at 9:12pm

Hi Colin,

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

Hope it helps,
Juan

Avatar
ccburns

Community Member, 79 Posts

4 November 2009 at 9:46pm

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

Avatar
Juanitou

Community Member, 323 Posts

4 November 2009 at 10:20pm

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.

Avatar
ccburns

Community Member, 79 Posts

4 November 2009 at 10:22pm

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

Cheers,
Colin