Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with collection inside other collection. #5944

Open
jbragui opened this issue Jul 19, 2016 · 1 comment
Open

Problem with collection inside other collection. #5944

jbragui opened this issue Jul 19, 2016 · 1 comment

Comments

@jbragui
Copy link

jbragui commented Jul 19, 2016

Hello. I am new in Symfony and I am working with this example: I have an Entity Called TypeOfAdmission which has an attribute called plans which is an array. Because of this, the relation between the entities TypeOfAdmission and Plan is from OneToMany. In the entity called Plan I have other attribute called subjects which is an array. Because of this, the relation between the entities Plan and Subject is from OneToMany...

It's like this: TypeOfAdmission -> Plan -> Subject ...

The problem is that when I am registering an instance of TypeOfAdmission I request to register Plans and the plans request subjects, everything goes well, but when saving it, the array of plans are saved well, but the array of subjects from every plan just get the last item registered.

I register this:
Admission Type 1
Plan 1
Subject 1
Subject 2
Plan 2
Subject 3
Subject 4

But on my database it is saved like this:
Admission Type 1
Plan 1
Subject 2
Plan 2
Subject 4

Anybody has had the same trouble?

Hope you can help me.

Thx in advance.

@Ocramius
Copy link
Member

Can you make an actual code example? Meanwhile, check https://gist.github.com/Ocramius/3121916, as it should clarify that you are responsible for setting all sides of the associations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants