I have a Merchant entity with the following fields and associations:-
/**
* @ORM\\ManyToMany(targetEntity=\"Category\", inversedBy=\"merchants\")
*/
public
Very detailed post, just to update the way of override and use the edit template in the Admin class.
Now, you should do it this way:
// src/AppBundle/Admin/EntityAdmin.php
class EntityAdmin extends Admin
{
public function getTemplate($name)
{
if ( $name == "edit" )
{
// template 'base_edit.html.twig' placed in app/Resources/views/Entity
return 'Entity/base_edit.html.twig' ;
}
return parent::getTemplate($name);
}
}
Or inject it in the service definition used the provided method, to keep the Admin class as cleaner as possible:
// app/config/services.yml
app.admin.entity:
class: AppBundle\Admin\EntityAdmin
arguments: [~, AppBundle\Entity\Entity, ~]
tags:
- {name: sonata.admin, manager_type: orm, group: "Group", label: "Label"}
calls:
- [ setTemplate, [edit, Entity/base_edit.html.twig]]