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.

Template Questions /

render function ?


Reply


3 Posts   1320 Views

Avatar
snaip

Community Member, 180 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, 180 Posts

17 June 2010 at 3:48am

??

Avatar
Willr

Forum Moderator, 5513 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();
}