doctrine2 - Flow3 - How to create a simple-to-use many-to-many relation? -
I am currently present between "project" and "person" in my first several-to-many relations in flow 3 I am working on and want to add, receive and remove elements of both controllers.
Project Announcement:
Class Project {// ... / ** * @ War Principles of Common Collections & lt; /*...*/ \ person & gt; * @ORM \ ManyToMany (targetEntity = "/*...*/" person ", mapped =" projects ") * $ / protected person; // ...}
person declaration:
class person {// ... / ** * @ wind / theory / common / collection \ Collection \ & lt; /*...*/ \ Project & gt; * @ORM \ ManyToMany (targetEntity = "/*...*/ \ project", invoked by = "person") * $ / protected projects; // ...}
But I can only add / remove objects on the "person" (inverse) side. At least I can get the object from both sides. Do I really need to make a workaround with a "person" object on the "project" side or do I have a simple solution?
Here is the code snippet of the project controller, which does not work:
public function addpersonAction () {$ param = $ this- & gt; Request-> GetArgument ('project'); $ Project = $ this- & gt; Project Resojiti- & gt; FindByIdentifier ($ Ultimate ['__ Identity']); $ Selected Persons = $ this- & gt; Request-> GetArgument ('selPersons'); ($ Person ['__ identification']); Gt; {$ Project- & gt; AddPerson ($ this-> person repository-> findByIdentifier ($ person ['__ detection'])); }} $ This-> Project Resor- gt; Update ($ Project); // ...}
and addPerson () function in the project:
public function addPerson (\ DS \ Datenbank \ Domain \ Model \ Person $ Person) {If (! $ This-> person-> contains ($ person)) $ this- & gt; Person- & gt; Add ($ person); }
This works for me I think the proper add in both of your models -Management is BTW: You do not need "distance of goal" in the flow, it is automatically detected automatically by the above announcement.
Is your database up to date? Did you flush the cache?
Comments
Post a Comment