Good day all
I am struggling with some "logical errors" in my code I believe...
I am trying to loop the Blogs I have on my site through the CMS to a Dropdown Menu on my "IssuePage".
I have got the Blogs to show on the dropdown but I am unable to save anything.
If you guys/gals have any ideas of what I could try that would be greatly appreciated!
Here is my code:
<?php
class IssuePage extends Page{
static $description = "A page Containing issues";
static $singular_name = 'IssuePage';
private static $db = array(
);
private static $has_many = array(
'IssuePage' => 'IssueExtension',
);
public function getCMSFields() {
$fields = parent::getCMSFields();
$gridFieldConfig=GridFieldConfig_RelationEditor::create(10);
$gridFieldConfig->addComponent(new GridFieldSortableRows('SortOrder'));
$gridField = new GridField("IssuePage", "Choose Blogs To Display", $this->owner->IssuePage()->sort("SortOrder"), $gridFieldConfig);
$fields->addFieldToTab("Root.Blogs", $gridField);
return $fields;
}
}
<?php
class IssueExtension extends DataObject {
public static $db = array(
'SortOrder'=>'Int',
'BlogPostName' =>'Varchar',
);
public static $has_one = array(
'IssueExtension'=>'IssuePage',
);
//Build the form fields in CMS
public function getCMSFields() {
// Create CMS Fields
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Blogs',
new GridField('BlogPost', 'All Blog Posts', BlogPost::get()));
$fields->addFieldToTab('Root.Main', new TextField('BlogPostName', 'Post Name '));
$fields->addFieldToTab('Root.Main',new DropdownField('IssueExtension','Select Blog Post', BlogPost::get()->map('ID')));
$fields->removeFieldFromTab('Root.Main','SortOrder'); // Dont need to display sort order
return $fields;
}
// Tell the datagrid what fields to show in the table
public static $summary_fields = array(
'BlogPostName' => 'BlogPostName',
);
public static $default_sort='SortOrder';
}
Regards
Skullies