Search code examples
symfonysymfony2-easyadmin

Prevent sorting results by a particular field in a EasyAdmin backend


Good afternoon,

I'm a beginner in symfony so I started to learn about bundles. I installed and configured EasyAdminBundle and it works fine.

My question is how can I disable "sort" in one field? I mean when I click on the sort button nothing happens.

Thank you for your help.


Solution

  • Internally EasyAdmin adds an option called sortable to each entity property. Since we don't restrict the options you can define for a property in the config.yml file, you can set this option explicitly for the fields you want to remove the sorting:

    easy_admin:
        # ...
        User:
            class: ...
            list:
                fields:
                    # ...
                    - { property: '...', sortable: false }