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