Jump to:

11004 Posts in 2735 Topics by 1824 members

All other Modules

SilverStripe Forums » All other Modules » Rendering subclassed UserDefinedForm w/alternative Form.ss

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 347 Views
  • mdt
    Community Member
    1 Post

    Rendering subclassed UserDefinedForm w/alternative Form.ss Link to this post

    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 Form.ss 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 http://doc.silverstripe.org/sapphire/en/topics/forms, 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


Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.