I have Symfony 2.3 + Sonata Admin + Sonata User Bundle.
I have created an entity Student
, and another entity Contact
. An Student
have one-to-many relationship with Contact
. I have added Contact
to Student
with sonata_type_collection
in my StudentAdmin
class. I also have created a group of users Operator
and assigned all permissions to Student
, but only list
and view
to Contact
.
My problem is that any user of Operator
can't add or delete Contact
(from Student edit page), but they can edit (and values are saved).
Any suggestions or examples?
Some code:
Roles assigned:
ROLE_SONATA_ADMIN_STUDENT_EDIT
ROLE_SONATA_ADMIN_STUDENT_LIST
ROLE_SONATA_ADMIN_STUDENT_CREATE
ROLE_SONATA_ADMIN_STUDENT_VIEW
ROLE_SONATA_ADMIN_STUDENT_DELETE
ROLE_SONATA_ADMIN_CONTACT_LIST
ROLE_SONATA_ADMIN_CONTACT_VIEW
ROLE_ADMIN: ROLE_USER, ROLE_SONATA_ADMIN
/**
* @ORM\OneToMany(targetEntity="MyBundle\Entity\Contact",
mappedBy="student",
cascade={"persist", "remove"})
**/
private $contact;
->add('contact', 'sonata_type_collection',
array(
'label' => 'Contact',
'by_reference' => false,
),
array(
'edit' => 'inline',
'inline' => 'table',
))
Thanks!