Disable search in Sonata Admin
Asked Answered
D

4

8

How can I disable the search feature in Sonata Admin Bundle, in order to not show the search input field in the upper menu?

Devinna answered 18/3, 2014 at 22:7 Comment(0)
F
5

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.

Fowling answered 19/3, 2014 at 7:58 Comment(2)
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
F
7

In Sonata Admin version >= 3.0 it's as simple as:

sonata_admin:
    search: false

in your config/packages/sonata_admin.yaml.

Forcible answered 25/7, 2019 at 13:10 Comment(2)
The cleanest solution on this postDelphina
AFAIK there was no such option at the time.Forcible
F
5

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.

Fowling answered 19/3, 2014 at 7:58 Comment(2)
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
T
5

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 %}
Trophic answered 5/9, 2017 at 11:10 Comment(0)
A
3

In later version (2.3+) ist the block sonata_sidebar_search that needs to be overwritten.

Ampoule answered 5/12, 2014 at 22:37 Comment(2)
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.