fix doIndex and doDelete of crud wrapper

This commit is contained in:
Simon Vieille 2021-05-12 10:49:38 +02:00
parent b556432f3e
commit a191db23e1
2 changed files with 6 additions and 3 deletions

View file

@ -44,7 +44,8 @@ abstract class CrudController extends AdminController
protected function doNew(EntityInterface $entity, EntityManager $entityManager, Request $request): Response
{
$form = $this->createForm($this->forms['new'], $entity);
$configuration = $this->getConfiguration();
$form = $this->createForm($configuration->getForm('new'), $entity);
if ($request->isMethod('POST')) {
$form->handleRequest($request);
@ -62,6 +63,7 @@ abstract class CrudController extends AdminController
return $this->render($configuration->getView('new'), [
'form' => $form->createView(),
'configuration' => $configuration,
'entity' => $entity,
]);
}
@ -79,7 +81,6 @@ abstract class CrudController extends AdminController
protected function doEdit(EntityInterface $entity, EntityManager $entityManager, Request $request): Response
{
$configuration = $this->getConfiguration();
$form = $this->createForm($configuration->getForm('edit'), $entity);
if ($request->isMethod('POST')) {
@ -105,6 +106,8 @@ abstract class CrudController extends AdminController
protected function doDelete(EntityInterface $entity, EntityManager $entityManager, Request $request): Response
{
$configuration = $this->getConfiguration();
if ($this->isCsrfTokenValid('delete'.$entity->getId(), $request->request->get('_token'))) {
$entityManager->delete($entity);

View file

@ -94,7 +94,7 @@
{% endblock %}
{% else %}
<tr>
<td class="col-12 text-center p-4 text-black-50">
<td class="col-12 text-center p-4 text-black-50" colspan="{{ configuration.fields('index')|length + 1 }}">
<div class="display-1">
<span class="fa fa-search"></span>
</div>