Login | Forgot password | Register

X

What is OpenID?

OpenID is an Internet-wide identity system that allows you to sign in to many websites with a single account.

With OpenID, your ID becomes a URL (e.g. http://username.myopenid.com/). You can get a free OpenID for example from myopenid.com.

For more information visit the official OpenID site.

Jump to:

759 Posts in 240 Topics by 249 members

Form Questions

SilverStripe Forums » Form Questions » UserDefinedForm on every page?

Page: 1
Go to End
Author Topic: UserDefinedForm on every page? 382 Views
  • chrisdarl
    avatar
    Community Member
    32 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 %>
    $Form
    <% end_control %>

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

    Any suggestions?

  • chrisdarl
    avatar
    Community Member
    32 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

    382 Views
Page: 1
Go to Top

Currently Online: CodeGuerrilla , Willr

Welcome to our latest member: jhstripe

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.