I'm having a little trouble understanding how the new GridField replaces some of the old interfaces. I'm trying to manage a $has_many relation on a page but when I create a new record using the GridField it doesn't automatically create the relation (just shows a drop down)
My DataObject Looks like this
class FAQ extends DataObject {
static $db = array(
'Question' => 'Varchar',
'Answer' => 'HTMLText'
);
static $has_one = array (
'FaqPage' => 'FaqPage'
);
static $summary_fields = array(
'Question' => 'Question',
'Answer' => 'Answer'
);
}
and the page looks like
class FaqPage extends Page {
/**
* Static vars
* ----------------------------------*/
static $description = 'Holds Frequently Asked Questions';
/**
* Data model
* ----------------------------------*/
static $has_may = array (
'FAQs' => 'FAQ'
);
/**
* Common methods
* ----------------------------------*/
public function getCMSFields() {
$fields = parent::getCMSFields();
$FAQ = FAQ::get()->filter(array('FaqPageID' => $this->ID));
$FAQField = new GridField("FAQs", "Frequently Asked Question", $FAQ, GridFieldConfig_RelationEditor::create());
$fields->addFieldToTab("Root.FAQs",$FAQField);
return $fields;
}
}
Not sure what I'm missing and the documentation doesn't appear to be clear
Thanks