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:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

$has_one and gridffield issues


Go to End


461 Views

Avatar
prashant2103

Community Member, 2 Posts

28 February 2014 at 10:39pm

Edited: 28/02/2014 10:43pm

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
{

}

?>