in my form, I tried to add new record with many-many relations using checkboxsetfield, but it returned the error "[User Error] Uncaught Exception: ManyManyList::add() can't be called until a foreign ID is set".
Anyone know what does it mean and how do I solve it?
The code is at the Page controller where you add your object, you may check out the structure of the codes in silverstripe tutorial http://doc.silverstripe.org/framework/en/tutorials/3-forms, my codes is as shown below:
class EventAddPage_Controller extends Page_Controller
public function doFrontEndForm($data, $form)
$Event = new Event();
$Event->write(); //for adding new record, it will have error when it comes to many-many relations if without write once before save