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.

Form Questions

UserDefinedForm on every page?

Go to End

16 Posts   4795 Views


13 June 2009 at 5:23am Community Member, 33 Posts

Hi there,

I've a page type ProjectPage and I want to have a UserDefinedForm on every page, isntead of creating that form every time I create a instance of the ProjectPage, is there any way that I can include it in?

I've tried doing the following :

Create a UserDefinedForm page; with URL QuickContactForm

in my ProjectPage_Controller class

function getForm() {
return DataObject::get_one('UserDefinedForm', 'URLSegment' = 'QuickContactForm');

in my template .ss file :
<% control getForm %>
<% end_control %>

BUT, I get a error page saying that "[User Error] Object::__call() Method 'Form' not found in class 'UserDefinedForm'"

Any suggestions?


13 June 2009 at 5:38am Community Member, 33 Posts

Solved now!

Just incase anyone else wants to do the same.. I've done :

class ProjectPage_Controller extends Page_Controller {
   public function getForm() {
      $record = DataObject::get_one("UserDefinedForm", "URLSegment = 'QuickContactForm'");
      $results = new UserDefinedForm_Controller($record);
      return $results;

This now works fine for me


21 April 2010 at 2:35am Community Member, 2 Posts


I had the same problem you had described, I did what you had mentioned as a solution, but how do i call the function in the template .ss file. Should i use $ Form or $UserDefinedForm or something else. Please help!!

Thanks in advance :)


24 April 2010 at 7:18pm Forum Moderator, 5511 Posts

@ajaycr - Use $Form. You use $UserDefinedForm only in the Content of the page.


27 June 2010 at 5:49am Community Member, 63 Posts

Thank you for posting your solution. Helped me enormously, as I wanted a quick contact form on every page too. Though to get it to work on ss 2.4 I had to use $getForm.Form on the Template and make sure there was a .php file in code, a .ss file in the template and one in the layout also.


25 August 2010 at 6:36am (Last edited: 25 August 2010 6:38am), Community Member, 80 Posts

I cannot figure this one out..

I want to have form on every page, it shows up fine on the frontpage, but as soon as I go to subpage, i am getting following error:

[User Error] Uncaught Exception: Object->__call(): the method 'fortemplate' does not exist on 'UserDefinedForm_Controller'
GET /silverstripe/stotte/

Line 724 in /home/childyef/public_html/silverstripe/sapphire/core/Object.php

716             default :
717                throw new Exception (
718                   "Object->__call(): extra method $method is invalid on $this->class:" . var_export($config, true)
719                );
720          }
721       } else {
722          // Please do not change the exception code number below.
724          throw new Exception("Object->__call(): the method '$method' does not exist on '$this->class'", 2175);
725       }
726    }
728    // -----------------------------------------------------------------------------------------------------------------
730    /**


* Object->__call(forTemplate,Array)
Line 447 of ViewableData.php
* UserDefinedForm_Controller->forTemplate()
Line 447 of ViewableData.php
* ViewableData->XML_val(Form,,1)
Line 41 of
* include(/tmp/silverstripe-cache-home-childyef-public_html-silverstripe/
Line 420 of SSViewer.php
* SSViewer->process(StandardSide_Controller,Zend_Cache_Frontend_Output)
Line 411 of SSViewer.php
* SSViewer->process(StandardSide_Controller)
Line 202 of Controller.php
* Controller->handleAction(SS_HTTPRequest)
Line 137 of RequestHandler.php
* RequestHandler->handleRequest(SS_HTTPRequest)
Line 147 of Controller.php
* Controller->handleRequest(SS_HTTPRequest)
Line 199 of ContentController.php
* ContentController->handleRequest(SS_HTTPRequest)
Line 67 of ModelAsController.php
* ModelAsController->handleRequest(SS_HTTPRequest)
Line 281 of Director.php
* Director::handleRequest(SS_HTTPRequest,Session)
Line 124 of Director.php
* Director::direct(/stotte/)
Line 127 of main.php

I am using 2.4.1, and $getForm.Form in template
I have php file, ss file in templates and another ss file in layout folder.. :)

plz help? thank you!


30 August 2010 at 2:43am Community Member, 8 Posts

Have you an idea on how to include a user defined form ( to a static sitebar ( ?
I use SS 2.4.1, tryed many variants described here but without success...


30 August 2010 at 7:53am Community Member, 12 Posts

I have been trying to do the same thing (put a form on staticsidebar). If you get an answer to this please post it up! Thanks.

Go to Top