Jump to:

2011 Posts in 1436 Topics by 620 members

Form Questions

SilverStripe Forums » Form Questions » UserDefinedForm on every page?

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

Page: 1 2
Go to End
Author Topic: 4713 Views
  • chrisdarl
    Community Member
    33 Posts

    UserDefinedForm on every page? Link to this post

    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?

  • chrisdarl
    Community Member
    33 Posts

    Re: UserDefinedForm on every page? Link to this post

    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

  • ajaycr
    Community Member
    2 Posts

    Re: UserDefinedForm on every page? Link to this post


    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

  • Willr
    Forum Moderator
    5508 Posts

    Re: UserDefinedForm on every page? Link to this post

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

  • BigChris
    Community Member
    63 Posts

    Re: UserDefinedForm on every page? Link to this post

    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.

  • janulka
    Community Member
    80 Posts

    Re: UserDefinedForm on every page? Link to this post

    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 .cache.home.childyef.public_html.silverstripe.themes.cbcf.templates.Layout.Page.ss
    * include(/tmp/silverstripe-cache-home-childyef-public_html-silverstripe/.cache.home.childyef.public_html.silverstripe.themes.cbcf.templates.Layout.Page.ss)
    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!

  • profimus
    Community Member
    8 Posts

    Re: UserDefinedForm on every page? Link to this post

    Have you an idea on how to include a user defined form (http://www.silverstripe.org/user-forms-module) to a static sitebar (http://www.ssbits.com/create-a-static-sidebar/) ?
    I use SS 2.4.1, tryed many variants described here but without success...

  • Spiggley
    Community Member
    12 Posts

    Re: UserDefinedForm on every page? Link to this post

    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.

Page: 1 2
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.