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.

Template Questions /

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

2.45 -> 2.46 form template problem


Go to End


1251 Views

Avatar
slavelabourer

Community Member, 26 Posts

11 January 2012 at 2:30pm

here is the code i have used for all my silvertripe sites up until 2.46


<?php

class EnquiryForm extends Page {


}
 
class EnquiryForm_Controller extends Page_Controller {
 
	function Form() {
		return new Form($this, "Form", new FieldSet(
 
			// List your fields here
			new TextField("Name", "Full name *"),
			new EmailField("Email", "Email address *"),
			new TextField("Phone", "Phone Number"),
			new TextareaField("Message", "Message", "3", "18")
				
		), new FieldSet(
 
			new FormAction("SubmitEnquiry", "Submit")
 
		), 
			
			new RequiredFields("Name", "Email")
		);
	}
	
	function SubmitEnquiry($data, $form) {
		
		$Enquiry = new Enquiry();
		$form->saveInto($Enquiry);
		
		$form->makeReadonly();
		$email = new Email;
		$email->to = 'email@email.com'; 
		$email->from = 'email@email.com';
		$email->subject = 'New Enquiry';
		$email->body = $form->forTemplate();
		$email->send();
		
		$Enquiry->write();
 		
			// Redirect to a page thanking people for registering
			Director::redirect('thanks-for-your-enquiry/');
 
	}	
}


?>

now on 2.46 i get this error: Generated with the default ContentController.ss template

I've never been able to move on to 2.46 because it breaks a lot of my templated code.
whats wrong here? and should I expect these kinds of problems with the upcoming 3.0 release?

thanks for you time,
peace,
dan.