0

I have this code to response with a form to create new customers:

public function getNewAction()
{
    $form = new CustomerType();

    $view = $this->view($form, 200)
    ->setTemplate("PlacasFrontendBundle:Customer:newCustomer.html.twig")
    ;

    return $this->handleView($view);

}

but when I request http://crm/app_dev.php/new the only I get rendered on browser is this:

{}

NOTE: I don't have any problems with this function below. I mean it returns a jsoned list of customers correctly:

public function getCustomersAction()
{

    $repository = $this->getDoctrine()->getRepository('PlacasFrontendBundle:Customer');

    $data = $repository->findAll();

    $view = $this->view($data, 200)
    ->setTemplate("PlacasFrontendBundle:Customer:getUsers.html.twig")
    ->setTemplateVar('users')
    ;

return $this->handleView($view);
}
tirenweb
  • 30,963
  • 73
  • 183
  • 303

1 Answers1

0
public function getNewAction()
{
    $form = new CustomerType();

    $view = $this->view($form, 200)
    ->setTemplate("PlacasFrontendBundle:Customer:newCustomer.html.twig")
    ->setHeader('Content-Type', 'text/html')
    ;

    return $this->handleView($view);
    ...

You need to set the proper Content-Type header.

piotr.jura
  • 810
  • 9
  • 17