I have a DataObject called Staff which has a many_many relationship with a DataObject called Stage (which in turn has a belongs_many_many relationship with Staff). When editing the Staff items, Stages are connected using a CheckboxSetField.
Here's the problem. If I check any of the checkboxes before clicking on Create, I get an exception saying "ManyManyList::add() can't be called until a foreign ID is set". If I create the Staff item first, and then checks any of the checkboxes everything works fine. It's the same kind of problem you get if you try to upload an image into an Image field, before the parent DataObject has been created.
Is there any way to fix this? I think it's an incredibly stupid bug/feature, if it's supposed to be like this. My clients won't understand that they have to click on Create before clicking on the checkboxes. Extremely confusing.
In Staff.php:
static $many_many = array(
"Stages" => "Stage"
);
In Stage.php:
public static $belongs_many_many = array(
'Staff' => 'Staff'
);