1
votes

Is there a way to remove the search functionality for ModelAdmin pages?

For now I'm using CSS, but there should be a better solution.

#filters-button {
    display: none;
}
1

1 Answers

4
votes

WE talked on IRC, but just for the record let me put this out here:

There has always been the possibility to overwrite public function SearchForm() { return false; } and therefore remove the form. This however does not effect the #filters-button (3.4) or the sidebar (3.0-3.3).
So at this time, you do have to use CSS.

I have however just created a Pull Request to implement $showSearchForm which would work the same way as $showImportForm.

https://github.com/silverstripe/silverstripe-framework/pull/6237
https://github.com/silverstripe/silverstripe-framework/pull/6309 (Re-raised Pull Request)

This will probably be merged into 3.4.2 3.5.0, once that is in you can do:

class FooBarAdmin extends ModelAdmin {
    private static $url_segment = 'foobar';
    private static $managed_models = ['Foo', 'Bar'];
    public $showImportForm = false;
    public $showSeachForm = false;
    # or if you just want to disable seach for Foo but not Bar:
    #public $showSeachForm = ['Bar'];
}