10812 Posts in 2496 Topics by 1785 members
|Go to End|
4 October 2013 at 7:33am Last edited: 7 October 2013 10:25pm
Everything works fine for simple DataObjects. Normal fields, has_one and has_many relations do work pretty well. (saving, reading, deleting, updating)
Now I implemented a new DataObject with a many_many relation to an existing DataObject. The existing DataObject also has the new one as a belongs_many_many relation.
I am able to create and read this new DataObject via the RESTFul API. But when creating a new one, my many_many relations are not written into the many_many table. And when I add the many_many relation to $api_access, I get an error when trying to view the DataObjects via REST:
ERROR [User Error]: Uncaught Exception: Object->__call(): the method 'fortemplate' does not exist on 'ManyManyList'
The $api_access on the new DataObject looks something like this: ("TimeTrackValues" is the many_many relation)
$api_access = array("Title", "ID", "Created", "MemberID", "TimeTrackValues")
The related DataObjects all have a canView function and are creatable/readable via the RESTFulServer. The only thing that doesnt work is the many_many relation.
Also I am not sure about, how to POST the `TimeTrackValues` ID Array..
My current implementation creates the following "POST Form" request Data in my Webinspector:
Comma separating, does not work ( TimeTrackValues:45,46,47 ).
I hope you guys understand what my problem is.
Sadly I couldn't find a documentation on the RestfulServer module that covers many_many relations. Maybe there is one I didn't find?
Thank you very much, I am thankful for any kind of help!
For anyone who might be interested, I found a solution by sending the ID's with a custom property (e.g. 'MyIDs'), catching them up in an onAfterWrite() hook and then adding them manually.
|Go to Top|