Search code examples
symfonysonata-admin

Sonata Admin seach block give the following error


i try to use the search block in Sonata admin:

An exception has been thrown during the rendering of a template ("Class does not exist").

and these errors: }, { 'query': query, 'admin_code': admin.code, 'page': 0, 'per_page': 10, 'icon': group.icon }) }} {% endif %} {% endfor %} {% endif %} {% endfor %}


Solution

  • this problem is displayed when no entity exists for some Bundle, i mean Bundles without Entities. I solved this Problem by escaping these Bundles in search.html.twig:

    {% if admin.code!= 'bundle.admin.bulkcoupon' and  admin.code!='bundle.admin.tools' %}
                            {{ sonata_block_render({
                                'type': 'sonata.admin.block.search_result'
                            }, {
                                'query': query,
                                'admin_code': admin.code,
                                'page': 0,
                                'per_page': 10,
                                'icon': group.icon
                            }) }}
            {% endif %}