I would like to register an entity with a modal form. In the template, I add the modal container in which I call a controller function :
<div id="periodFormModal" tabindex="-1" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">{{ 'periods.updating.text'|trans }}</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
{{ render(controller('AppControlleradvertAdvertPeriodController::new', {'request': app.request, 'id': advert.id})) }}
</div>
</div>
</div>
</div>
In the controller function, after the registering, to update the template with new created informations, I make a redirection to this template :
if ($form->isSubmitted() && $form->isValid())
{
//
$manager->persist($period);
$manager->flush();
$element = $this->translator->trans('period.flash') . ' ';
$message = $this->translator->trans('success.creation.flash', ['element' => $element, 'gender' => 'feminine', 'number' => 1]);
$this->addFlash('success', $message);
return $this->redirectToRoute('advert.periods.fullcalendar', array('id' => $advert->getId()));
}
When redirection, the entity is correctly registered but I have this error :
An exception has been thrown during the rendering of a template ("Error when rendering "https://127.0.0.1:8000/en/advert/periods/fullcalendar/1" (Status code is 302).").
Source: Symfony Questions
Was this helpful?
0 / 0