I want to fully customize the way expanded choice looks in the admin edit form. I have found a template that shows it:
vendor/sonata-project/admin-bundle/Resources/views/Form/form_admin_fields.html.twig
I also have found a list of templates you can override in SonataAdmin https://sonata-project.org/bundles/admin/master/doc/reference/templates.html Unfortunately, there is not form_admin_fields.html.twig in the list. So I'm wondering how can override that template or at least {% block choice_widget_expanded %} from that template.
I believe this has to be overridden on the level of the storage bundle.
For instance, if using Doctrine and SonataAdminDoctrineOrmBundle, it can easily be overridden in configuration like so:
sonata_doctrine_orm_admin:
templates:
form: ["My/Templates/form_admin_fields.html.twig"]
Be sure to extend the doctrine form_admin_fields.html.twig in your own form_admin_fields.html.twig (rather than the base sonata admin twig file), ie:
{% extends '@SonataDoctrineORMAdmin/Form/form_admin_fields.html.twig' %}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.