I'm trying to move from a messy PHP template structure, with many duplicated code, to slots to help us having a similar twig philosophy with the extends.
The problem that we have is that some templates are rendering the HTTP Headers:
The code for Form/form.html.php is:
<?php
/**
* @var \Symfony\Bundle\FrameworkBundle\Templating\TimedPhpEngine $view
* @var \Symfony\Bundle\FrameworkBundle\Templating\Helper\FormHelper $formHelper
* @var \Symfony\Component\Templating\Helper\SlotsHelper $slotsHelper
* @var \Symfony\Component\Form\FormView $form
*/
$formHelper = $view['form'];
$slotsHelper = $view['slots'];
?>
<div class="form-wrapper">
<?php $slotsHelper->output('form-start', $formHelper->start($form)) ?>
<?php $slotsHelper->output('form-widget', $formHelper->widget($form)) ?>
<?php $slotsHelper->output('form-end', $formHelper->end($form)) ?>
</div>
And the code for the other template, Form/Order/form.html.php, is
<?php
/**
* @var \Symfony\Bundle\FrameworkBundle\Templating\TimedPhpEngine $view
* @var \Symfony\Bundle\FrameworkBundle\Templating\Helper\FormHelper $formHelper
* @var \Symfony\Component\Templating\Helper\SlotsHelper $slotsHelper
* @var \Symfony\Component\Form\FormView $form
*/
$formHelper = $view['form'];
$slotsHelper = $view['slots'];
$view->extend(':Form:form.html.php');
$slotsHelper->start('form-widget');
echo $formHelper->widget($form);
$slotsHelper->stop();
In the Controller, I'm rendering the form as always I've rendered a form:
$this->render("Form/Order/form.html.php", ['form' => $orderForm->createView()])
If I change this sentence by "returned string", Symfony prints only this "returned string", not the headers.
The form is rendered correctly, but for some reason that I cannot understand, Symfony is printing the HTTP Headers.
Thanks!