I have an entity. I need to execute some JS code when entity loads in a popup.
Is there any way to add a custom JS/HTML code to an entity form via admin class configuration. E.g. to pass a template as an option
I have an entity. I need to execute some JS code when entity loads
Share
You can do it this way:-
Add a class parameter in your FormMapper like this:-
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add(‘description’, null, array(‘attr’ => array(‘class’ => ‘for_popup’), ‘required’ => false))
}
Extend the
edit.html.twig/base_edit.html.twigfrom Sonata CRUD Templates—edit.html.twig—-
—base_edit.html.twig—
Use your
edit.html.twiginstead of Sonata CRUD’s by defining it in the getEditTemplate function (within your Admin class).You can also set the custom edit template when you inject the admin service.