Jump to:

23545 Posts in 19310 Topics by 2888 members

General Questions

SilverStripe Forums » General Questions » How does page/action/ID construct work

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

Page: 1
Go to End
Author Topic: 1422 Views
  • zenmonkey
    Community Member
    528 Posts

    How does page/action/ID construct work Link to this post

    I'm trying to figure out how the page/action/ID construct works, but the documentation page doesn't exist.

    I have a Product Review form in my Product_Controller. In the template the Form Gets automagically Hidden and Revealed with jQuery. However when I add the reCaptcha plug-in all hell breaks loose. I figure the problem is the AJAX call in reCaptcha doesn't like to be called into a HIdden div. So I thought why don't I make the form generation an AJAX call.

    Reading the AJAX intro in the REcipes section I understand I need to call DataObjects as pages, and tell the page controller to use a differnrt tempalte for AJAX calls. But I can't get the form to Render in its own Page.

    Here is the Form Function if it Helps

    class Product_Controller extends Page_Controller {
        * Include the product group's requirements, override if the project has the file,
        * otherwise use the module one instead
       function init(){

       /**Create Review Form****
       function UserProductReviewForm() {
    // Create fields
        $recaptchaField = new RecaptchaField('MyCaptcha');
        $recaptchaField->jsOptions = array('theme' => 'white');
    $fields = new FieldSet(
                          new TextField('Name','Name:'),
                          new EmailField('Email','E-Mail Address:'),
                          new TextField('Location','Location:'),
                          new OptionsetField('Rating','Rating',array(
                                                          '1' => '1',
                                                          '2' => '2',
                                                          '3' => '3',
                                                          '4' => '4',
                                                          '5' => '5',
                          new TextField('Title','Review Title:'),
                          new TextareaField('Review'),
                          new HiddenField('ProductID', '', $this->ID),
                          new HiddenField('ProductName','',$this->Title)
    // Create actions
    $actions = new FieldSet(
    new FormAction('doReview', 'Submit')

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


    function doReview($data, $form) {
    $review = new Review();

    I've commented out the offending reCaptcha element. Shouldn't I be able to load the form with


  • Willr
    Forum Moderator
    5511 Posts

    Re: How does page/action/ID construct work Link to this post

    Shouldn't I be able to load the form with mysite.com/product-name/UserProductReviewForm

    No as UserProductReviewForm returns a Form Object. You would include $UserProductReviewForm in the main product name page to load the form or make your own action which just returns an array

    function addreview() {
    return array(
    'Title'=> "Add Review",
    'Form' => $this->UserProductReviewForm()

    Then you would go mysite.com/product-name/addreview and have the ability to have a ProductPage_addreview.ss template which has the $Form var to load your form.

    Documentation is a bit light on this but its started.


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