Search code examples
ajaxsymfonysonata-admin

Sonata Admin Dependent Select ajax returns empty value


I have form with dependent selectBoxes. I read tutorial http://symfony.com/doc/current/form/dynamic_form_modification.htmL

But in my representation ajax always return empty value I use Sonata Admin


Solution

  • You controller Action must implement method:

     if ($request->isXmlHttpRequest()) {
            return $this->render('MyBundle:Task:ajax-template.html.twig', [
               'form' => $view,
            ]);
        }
    

    And template:

    {{ form_start(form) }}
    {{ form_end(form) }}