Hello all,
I just try to set up a many-to-many relation between two Dataobjects. Let´s say Events and Countries.
An event can be assigned to many countries and one country could be assigned to many events.
The relation setup seems to work basically. I have a Gridfield in the EventsPage showing all Events:
//EventItem.php
static $many_many = array(
'CountryItems' => 'CountryItem'
);
//CountryItem.php
static $belongs_many_many = array(
'EventItems' => 'EventItem'
);
//EventPage.php
function getCMSFields() {
$fields = parent::getCMSFields();
$gridfield = new GridField("Events", "My Events", $this->Events(), new GridFieldConfig_RelationEditor());
$fields->addFieldToTab('Root.Events', $gridfield);
return $fields;
}
If I click an Event there appears a Tab in the right top corner showing the countries. I can add and delete countries there. But they are only assigned to a single event (the one that was previously selected). I need a country list showing all countries that were ever created and with a checkbox for each country. so I can add and remove countries with just setting or deleting the relation. I think in former days it was called ManyManyComplexTableField...
any help is highly appreciated.
many thanx,
florian