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:

All other Modules /

Discuss all other Modules here.

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

Rendering subclassed UserDefinedForm w/alternative

Go to End



Community Member, 1 Post

16 December 2011 at 4:40am

SS 2.4
UF 0.4

I've successfully subclassed UserDefinedForm and have the page rendering with the correct Layout. I now need to specify an alternative template for the form itself to use for rendering. How can I overide the UserDefinedForm forTemplate() from my subclass controller; something like the example from, but using UserDefinedForms:

class MyForm extends Form {

function __construct($controller, $name) {
$fields = new FieldSet(
new TextField('FirstName', 'First name'),
new EmailField('Email', 'Email address')

$actions = new FieldSet(
new FormAction('submit', 'Submit')

parent::__construct($controller, $name, $fields, $actions);

function forTemplate() {
return $this->renderWith(array(

function submit($data, $form) {
// do stuff here