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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Transferring post data between templates


6 Posts   564 Views


24 May 2012 at 2:17am Community Member, 15 Posts

Hi, I'm starting out on Silverstripe and for starters I want to do something simple: construct a form on one template (call it then display the results you choose on another template (call it but I'm having trouble figuring this out

My form is standard fare:

$fields = [array of fields]

$actions = new FieldSet(
new FormAction('order', 'Place Order')

return new Form($this, 'order', $fields, $actions);

I thought I could use this to load a separate template for the forms post data but this just gives me a blank screen

function order($data, $form) {
return $this->customise(array('data' => $data))->renderWith('order');

I'm sure there is a simple way to get Silvertripe to display post data to a seperate template. What have I overlooked?

I searched beforehand but I couldn't find a viable answer


26 May 2012 at 8:04pm Forum Moderator, 5511 Posts

You may need to use an ArrayData object for returning data to the template.

function order($data, $form) {
return $this->customise(new ArrayData(array(
'Data' => $data

Then you can use $Data.Something in the template or to simplify

function order($data, $form) {
return $this->customise(new ArrayData($data))->renderWith('order');


29 May 2012 at 8:38pm (Last edited: 29 May 2012 8:45pm), Community Member, 15 Posts

Thanks for the reply Willr

I gave the Arraydata object a shot, following your example. Though upon execution it seems another issue has cropped up:

[Warning] Missing argument 2 for Menu_Controller::order(), called in C:\xampp\htdocs\ss_testing\sapphire\core\control\Controller.php on line 193 and defined"

I'm not sure what why it is suddenly complaining about the $form variable in "function order($data, $form)". The form follows the Silverstripe form tutorials and they use the same syntax I am using.

I tried shortening the function to "function order($data)", this resulted in a different error:

[User Warning] None of these templates can be found in theme 'blackcandy':

This comes despite the template being in the layouts folder and is used without problem by another page.

Did I miss something?


31 May 2012 at 2:55am Community Member, 15 Posts

Never mind [url=]this thread contained the answer I was looking for[/url] in regards to that bug I came across

return new Form($this, 'order', $fields, $actions);

Needed to be

return new Form($this, 'createsubmit', $fields, $actions);

Now the order template appears and a little test code displays the post data on it.

However only the HTML on the template is returned, I lost the rest of the theme. It seems that "RenderWith" quite literally renders only the template you give it and nothing else.

I'm sure I don't need to include all the headers and footers inside the order template, is there a way to tell silverstripe to load the whole theme and only change the page of the theme?

If not, perhaps I will need to use AJAX


31 May 2012 at 5:31pm Forum Moderator, 5511 Posts

renderWith() takes an array of template names to build up it's view so you can get it to fallback like renderWith(array('Page_Order', 'Page'))


2 June 2012 at 7:54pm Community Member, 15 Posts

"renderWith(array('Order', 'Page'));" was the correct solution. So far so good.

I should add that one thing that added to the confusion was leaving a duplicate of the Order template inside the includes folder. That preventing RenderWith from finding the order template inside the layouts folder. Deleting the duplicate fixed that quickly. So for those reading this...yea...don't do that.