Jump to:

23459 Posts in 18906 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » $has_one and gridffield issues

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: 163 Views
  • prashant2103
    Avatar
    Community Member
    2 Posts

    $has_one and gridffield issues Link to this post

    Please help to resolve following issue

    i unable to create page, i got following error :

    Error at line 137 of C:\xammp\htdocs\aac-uk\trunk\application\live\framework\forms\gridfield\GridField.php

    My Code is :

    <?php
    class TestimonialPage extends Page
    {
    private static $has_one = array ('Testimonials' => 'Testimonial');

    public function getCMSFields()   
    {
        $fields = parent::getCMSFields();
    // Create a default configuration for the new GridField, allowing record editing
    $config = GridFieldConfig_RelationEditor::create();
    // Set the names and data for our gridfield columns
    $config->getComponentByType('GridFieldDataColumns')->setDisplayFields(array(
    'Photo' => 'Photo',
    'TestimonialPage'=> 'TestimonialPage' // Retrieve from a has-one relationship
    ));
    // Create a gridfield to hold the Testimonial relationship
    $testimonialsField = new GridField(
    'Testimonials', // Field name
    'Testimonial', // Field title
    $this->Testimonials(), // List of all related Testimonial
    $config
    );
    // Create a tab named "Testimonial" and add our field to it
    $fields->addFieldToTab('Root.Testimonial',$testimonialsField);
    return $fields;
          
    }

    }

    class TestimonialPage_Controller extends Page_Controller
    {

    }

    ?>

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