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:

Data Model Questions /

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

SS3 has_many relations

Go to End



Community Member, 545 Posts

25 July 2012 at 3:45am

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());
		 return $fields;


Not sure what I'm missing and the documentation doesn't appear to be clear