How can I disable the search feature in Sonata Admin Bundle, in order to not show the search input field in the upper menu?
Disable search in Sonata Admin
Asked Answered
You need to override the standard_layout.html.twig template and overwrite the block sonata_top_bar_search with nothing in it. That will make it disappear.
sonata_admin:
templates:
layout: YourBundle::layout.html.twig
Read more here about customizing templates.
Thanks! I thought there will be a parameter or something similar, but this seems to be the only option so far. –
Rafe
As mentioned below by @monofone: "In later version (2.3+) ist the block sonata_sidebar_search that needs to be overwritten." –
Liebermann
In Sonata Admin version >= 3.0 it's as simple as:
sonata_admin:
search: false
in your config/packages/sonata_admin.yaml
.
The cleanest solution on this post –
Delphina
AFAIK there was no such option at the time. –
Forcible
You need to override the standard_layout.html.twig template and overwrite the block sonata_top_bar_search with nothing in it. That will make it disappear.
sonata_admin:
templates:
layout: YourBundle::layout.html.twig
Read more here about customizing templates.
Thanks! I thought there will be a parameter or something similar, but this seems to be the only option so far. –
Rafe
As mentioned below by @monofone: "In later version (2.3+) ist the block sonata_sidebar_search that needs to be overwritten." –
Liebermann
Just complementing the answers here, the complete solution:
config.yml
sonata_admin:
templates:
layout: AppBundle::layout.html.twig
AppBundle::layout.html.twig
{% extends 'SonataAdminBundle::standard_layout.html.twig' %}
{% block sonata_sidebar_search %}
{% endblock sonata_sidebar_search %}
In later version (2.3+) ist the block sonata_sidebar_search that needs to be overwritten.
This is more suited as a comment on the answer. –
Wellestablished
Yes, you are right but I can`t comment due to reputation. –
Ampoule
© 2022 - 2024 — McMap. All rights reserved.