For one of my objects I need to create some dynamic form rendering... But I cant figure out how to do this in Sonata Admin. For example when I create an object I have a fiel
If I have realy understand your need you have to use ajax of course, first you need to add new admin route to this EntityAdminController to do it you have to override the configureRoutes method and to add your new route like this :
protected function configureRoutes(RouteCollection $collection)
{
$collection->add('reloadCities', 'realod-cities');
}
Then you have to create a new controller which gonna have the action definition for your new route like :
use Sonata\AdminBundle\Controller\CRUDController as BaseController;
class CitiesController extends BaseController
{
public function reloadCitiesAction()
{
// some code
return $this->render(...);
}
}
Then you have to override the SonataAdminBundle:CRUD:edit.html.twig
template and set your javascript event listener like this :
{% extends 'SonataAdminBundle:CRUD:edit.html.twig' %}
{% block form %}
{{ parent() }}