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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Template Questions /

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

render function ?


Go to End


3 Posts   1831 Views

Avatar
snaip

Community Member, 181 Posts

15 June 2010 at 9:04pm

Edited: 15/06/2010 9:04pm

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

Avatar
snaip

Community Member, 181 Posts

17 June 2010 at 3:48am

??

Avatar
Willr

Forum Moderator, 5523 Posts

17 June 2010 at 2:18pm

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();
}