Hi everyone!
I'm creating a "contact us" form using subclassing method describing here: http://doc.silverstripe.org/doku.php?id=form
Unfortunately, method responsible for performing submission declared in my form subclass isn't called. Take a look at the code below:
class SupportForm extends Form {
function __construct($controller, $name) {
$fields = new FieldSet(
new TextField('FirstName', 'First name'),
new EmailField('Email', 'Email address'),
new TextareaField('Message')
);
$actions = new FieldSet(
new FormAction('submit', 'Submit')
);
$validator = new RequiredFields('Email', 'Message');
parent::__construct($controller, $name, $fields, $actions);
}
function forTemplate() {
return $this->renderWith(array(
$this->class,
'Form'
));
}
public function submit($data, $form) {
die("This code is never called");
}
}
class ContactUs extends Page {
}
class ContactUs_Controller extends Page_Controller {
public function Form() {
return new SupportForm($this, "SupportForm");
}
}
Or see more this code in more convenient form: http://pastie.org/834032
Just for information: I've also created includes/SupportForm.ss template to display this form data.
What I'm doing wrong?