I have a one to many
relationship between account and contacts. I use sonata admin bundle
I want to display all contacts of an account in the view detail of an account ( ConfigureShowFields
in AccountAdmin
class)
in class AcountAdmin.php
i have :
protected function configureShowFields(ShowMapper $showMapper)
{
$showMapper
# .......
->with('Liste des contacts', array('class' => 'col-md-12'))
->add('contacts')
->end()
;
}
I believe you can do this via sonata_type_collection.
->add('contacts', 'sonata_type_collection', array(
'associated_property' => 'email',
'route' => array(
'name' => 'show'
),
'admin_code' => 'app.admin.contacts',
))
The associated_property is the associated property found in the Contacts entity, and the admin_code is the contacts admin.