Lets imagine I want to create a task app.
In this app I have users, eg
id name
1 phil
2 anette
Every user can have x amount of task lists, eg
id user_id name
1 1 test
2 1 another test
3 2 cheers
Again, every task list can have a list of tasks, eg:
id tasklist_id name
1 1 very important task
2 2 important task
3 1 another task in first list
4 3 item for anette
The entity mapping with Doctrine worked out fine. Also the integration of FOSUserBundle . I actually can login as an user and can see my very own task lists.
But what it not possible for me to create is a way so that a user can edit the tasks in a task list. Also it should be noted that only the user which owns a specific task list should be able to edit it and its childs. Via my approach (auto generated crud templates) you can take any id and change every content.
What I thought about to this point:
php app/console generate:doctrine:crud
) symfony2 pass parameter to subentity
or symfony2 pass controller variable
) but could not find any information to this topic other than changing the controller into a service Which are correct ways regarding symfony2 to solve this (almost certainly common) problem? How can I supply a user with a way to edit his tasks lists, but also to edit specific tasks? Or to be more generic, how to edit more than one one-to-many relationships in symfony?
You should take a look at How to Embed a Collection of Forms
Concerning your security problem, this is a different matter, but you should check in your controller (in EditAction) that the list you're trying to edit belongs to the logged in user.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.