Hi
I am a little confused. I have a CustomerproductPage, a Custom ProcuctfotoForm, a DataObject Customerproduct, a DataObjec Extension for many_many Images (Customerproduct_ProdcutphotoExtension) and another CustomerproductDetail Page for showing details, saving, editing.
Now I have a method like this on my DataObject Customerproduct
public function Productphoto() {
return $this->getManyManyComponents(
'Productphoto',
'',
"\"Customerproduct_Productphoto\".\"ID\" ASC"
);
}
Actuall, this is ok..I can receive on two pages the relation Data. But this is the problem. I just can save on one Page to the relation the Images but on the other page not. It does just show, means I get by sql query the relation data, but I can't save it
on the CustomerproductPage (custom form of the page) it works, I have this:
$productobj = DataObject::get_by_id('Customerproduct', $productID);
$productobj->Productphoto()->CustomerproductID = $productID;
$productobj->Productphoto()->ImageID = $fileID;
$arr = array($productobj->ID,$productobj->Productphoto()->ImageID = $fileID);
$productobj->Productphoto()->addMany($arr);
But on the CustomerproductDetail Page I try to do the same, it does not work.
I receive also by Debug the right Data from this manymanylist
$list = new ManyManyList('Customerproduct_Productphoto','Customerproduct', 'ID', 'CustomerproductID');
My question is now, how can I save on the second Page, the detail Page, my Data which I receive through a form?
When I try this by Debug...it says the following;
$product = Customerproduct::get()
->where("\"ID\" = '$id'");
// $list = new ManyManyList('Customerproduct_Productphoto','Customerproduct', 'ID', 'CustomerproductID');
$test = $product->Productphoto()->ImageID;
Debug::show($test);
[User Error] Uncaught Exception: Object->__call(): the method 'productphoto' does not exist on 'DataList'
Can anyone help?
Thanks a lot!