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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Archive /

Our old forums are still available as a read-only archive.

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

Custom form doesn't work

Go to End

2 Posts   2314 Views


Community Member, 54 Posts

12 April 2007 at 2:53pm


This is in 2.0.1rc6.

I have a custom form, the code to build it looks like this:

class ContactPage_Controller extends Page_Controller {

function Form() {
return new Form($this, "ContactForm", new FieldSet(
// List the your fields here
new TextField('SenderName'),
new EmailField("Email", "Email address")
), new FieldSet(
// List the action buttons here
new FormAction('doSendEmail', 'Submit')

), new RequiredFields(
// List the required fields here: "Email", "FirstName"
function doSendEmail($data, $form){
die('not yet implemented');

Which looks like it should be fine, however I get an error message:

Fatal error: Call to a member function setForm() on a non-object in **siterootremoved**/www/sapphire/forms/Form.php on line 37

Any ideas?


Community Member, 54 Posts

12 April 2007 at 2:57pm

never mind. This is a bug in my code, not yours ;)