Hi all
I am trying to create a simple testimonials page, with using the new gridfield in SS3 I am running 3.1.0 and I also have silverstripe-gridfield-betterbuttons module, my code bellow
Testimonial.php
<?php
class Testimonial extends DataObject {
public static $db = array(
'Name' => 'Varchar(255)',
'Testimonial' => 'Varchar(255)'
);
public static $has_one = array(
'TestimonialsPage' => 'TestimonialsPage'
);
public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->removeFieldFromTab("Root.Main","TestimonialsPageID");
return $fields;
}
}
TestimonialsPage.php
<?php
class TestimonialsPage extends Page {
public static $has_many = array(
'Testimonials' => 'Testimonial' // Link the Testimonial Items
);
public function getCMSFields() {
$fields = parent::getCMSFields();
// Create a default configuration for the new GridField, allowing record editing
$config = GridFieldConfig_RecordEditor::create();
$config->getComponentByType('GridFieldDataColumns')->setDisplayFields(array(
'Name' => 'Name',
'Testimonial' => 'Testimonial'
));
// Create a gridfield to hold the student relationship
$testimonialsField = new GridField(
'Testimonial', // Field name
'Testimonials', // Field title
$this->Testimonials(), // List of all related students
$config
);
// Create a tab named "Students" and add our field to it
$fields->addFieldToTab('Root.Testimonials', $testimonialsField);
return $fields;
}
}
class TestimonialsPage_Controller extends Page_Controller {
}
When I click save and add another button in CMS i get the below error in the CMS am I doing something wrong here? the record actually gets added also.
Warning at line 673 of /framework/forms/gridfield/GridField.php
Thanks in advance
FireMe!
Posted to: Simple Testimonials page problem | Show Thread | Post Reply