Jump to:

3392 Posts in 976 Topics by 852 members

Template Questions

SilverStripe Forums » Template Questions » render function ?

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

Page: 1
Go to End
Author Topic: 1242 Views
  • snaip
    Avatar
    Community Member
    180 Posts

    render function ? Link to this post

    hi

    i try to add newsletter form to my site

    i've create new code/RegistrationForm.php like here http://doc.silverstripe.org/recipes:forms

    also created RegistrationForm.ss in templates/includes only with this code

    $Form

    in layout puting <% include RegistrationForm %> but nothing, no form rendering

    so how to render function from other classes which are not extends

    example 1

    class A extend B {
    }

    class B extend Page_Controller {
    function Form() {
    };
    }

    in A.ss $Form will be works

    example 2

    class A extends Page_Controller {
    }

    class B extends Page_Controller {
    function Form() {
    };
    }

    in A.ss $Form will not be works

  • snaip
    Avatar
    Community Member
    180 Posts

    Re: render function ? Link to this post

    ??

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: render function ? Link to this post

    Well in example #2 - A does not extend B, A does not know about B. How is it meant to render if it has no idea of its existing. To get the function Form() you would have to create a new B (since you don't have a b)

    class A extends Page_Controller {

    function Form() {
    $b = new B();

    return $b->Form();
    }

    1242 Views
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.