I've created a number of Gridfields with GridFieldConfig_RelationEditor for some many_many relationships.
The way this works is not ideal as the user must know what has already been added to be able to search for it.
Is there a way to achieve similar to what we used be able to do with the Dataobjectmanager. ie displaying every item and allow them to select the ones they want with a checkbox?
Activity.php
<?php
class Activity extends DataObject{
public static $db = array(
'Title' => 'Varchar(255)',
'Summary' => 'Text'
);
static $belongs_many_many = array(
'TourPages' => 'TourPage'
);
public static $summary_fields = array(
'Title' => 'Title'
);
public function getCMSFields_forPopup() {
return new FieldList(
new TextField('Title', 'Title'),
new TextareaField('Summary', 'Brief Summary')
);
}
}
TourPage.php
....
static $many_many = array(
'Activities' => 'Activity'
);
.....
$gridField = new GridField("Activities", "Activities", $this->Activities(), new GridFieldConfig_RelationEditor);
$fields->addFieldToTab("Root.Activities", $gridField);