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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Form Questions /

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

UserDefinedForm on every page?


Go to End


16 Posts   9506 Views

Avatar
chrisdarl

Community Member, 33 Posts

13 June 2009 at 5:23am

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 %>
$Form
<% end_control %>

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

Any suggestions?

Avatar
chrisdarl

Community Member, 33 Posts

13 June 2009 at 5:38am

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

Avatar
ajaycr

Community Member, 2 Posts

21 April 2010 at 2:35am

Hello,

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 :)

Avatar
Willr

Forum Moderator, 5523 Posts

24 April 2010 at 7:18pm

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

Avatar
BigChris

Community Member, 63 Posts

27 June 2010 at 5:49am

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.

Avatar
janulka

Community Member, 80 Posts

25 August 2010 at 6:36am

Edited: 25/08/2010 6:38am

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
Source

715 				
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.
723 			
724 			throw new Exception("Object->__call(): the method '$method' does not exist on '$this->class'", 2175);
725 		}
726 	}
727 	
728 	// -----------------------------------------------------------------------------------------------------------------
729 	
730 	/**

Trace

    * 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!

Avatar
profimus

Community Member, 8 Posts

30 August 2010 at 2:43am

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...

Avatar
Spiggley

Community Member, 12 Posts

30 August 2010 at 7:53am

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