Faloude Faloude - 1 month ago 17
PHP Question

SilverStripe remove ModelAdmin search

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;
}

Answer

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

This will probably be merged into 3.4.2, 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'];
}
Comments