Hi
There is something wrong with the GridField code in this module, can you please help me try and fix it?
Thanks
<?php
class Home extends Page {
private static $db = array(
'ContentHeader' => 'Text',
'ContentTwoHeader' => 'Text',
'ContentTwoContent' => 'Text',
'ContentThreeHeader' => 'Text',
'ContentThreeContent' => 'Text',
'ContentFourHeader' => 'Text',
'ContentFourContent' => 'Text',
'ContentFiveHeader' => 'Text',
'ContentFiveContent' => 'Text',
'ContentSixHeader' => 'Text',
'ContentSixContent' => 'Text'
);
public static $has_many = array (
'SliderPicture' => 'HomeSlider'
);
public function getCMSFields() {
$f = parent::getCMSFields();
$config = GridFieldConfig_RecordEditor::create();
$sliders = new GridField("SliderPicture", "SliderPicture", $this->SliderPicture(), $config);
$f->addFieldToTab('Root.Events', $sliders);
$f->addFieldToTab('Root.Main', new TextField('ContentHeader'), 'Content');
$f->addFieldToTab('Root.Main', new TextField('ContentTwoHeader'), 'Content');
$f->addFieldToTab('Root.Main', new TextField('ContentTwoContent'), 'Content');
$f->addFieldToTab('Root.Main', new TextField('ContentThreeHeader'), 'Content');
$f->addFieldToTab('Root.Main', new TextField('ContentThreeContent'), 'Content');
$f->addFieldToTab('Root.Main', new TextField('ContentFourHeader'), 'Content');
$f->addFieldToTab('Root.Main', new TextField('ContentFourContent'), 'Content');
$f->addFieldToTab('Root.Main', new TextField('ContentFiveHeader'), 'Content');
$f->addFieldToTab('Root.Main', new TextField('ContentFiveContent'), 'Content');
$f->addFieldToTab('Root.Main', new TextField('ContentSixHeader'), 'Content');
$f->addFieldToTab('Root.Main', new TextField('ContentSixContent'), 'Content');
return $f;
}
}
class Home_Controller extends Page_Controller {
public function init() {
parent::init();
}
}
<?php
class HomeSlider extends DataObject
{
public static $db = array(
'Title' => 'Text',
'Button' => 'Text',
'LinkSite' => 'Text'
);
public static $has_one = array(
'Picture' => 'Image'
);
public function getCMSFields() {
$f = new FieldList();
$f->push( new TextField('Title', 'Title for the slider') );
$f->push( new TextField('Button', 'Button for the slider') );
$f->push( new TextField('LinkSite', 'Link for the slider picture') );
$f->push( new UploadField('Picture', 'Image file'));
return $f;
}
}
?>