Is it possible to override the template for the form type: "sonata_type_collection"?
Ive tried along these lines:
$formMapper->add('slides', 'sonata_type_collection', array(), array(
'edit' => 'inline',
'inline' => 'table',
'sortable' => 'priority',
'template' => 'MyBundle:Form:slides.admin.html.twig'
));
but to no avail.
I know I could override the entire template, but I only want to do it for this form, not all the places where I use this form type.
Does anyone know if this is possible?
Thanks
I found a great bit of code in
/vendor/sonata-project/admin-bundle/Sonata/AdminBundle/Form/Extension/Field/Type/FormTypeFieldExtension.php
which actually sets up an array of types to attach to the form view which it uses to prioritise twig block rendering: (lines 99 to 105)Therefore all I had to do was define a block called
mycompany_admin_content_galleries_sonata_type_collection_widget
ormycompany_admin_content_galleries_slides_sonata_type_collection_widget
and it only applies to this admin form :)To complete this solution in my Admin class I added this function:
and I created
MyBundle/Resources/views/Gallery/admin.slides.html.twig
, containing the following: