SilverStripe删除ModelAdmin搜索

时间:2016-10-26 09:49:53

标签: php silverstripe

有没有办法删除ModelAdmin页面的搜索功能?

目前我正在使用CSS,但应该有更好的解决方案。

#filters-button {
    display: none;
}

1 个答案:

答案 0 :(得分:4)

我们在IRC上谈过,但只是为了记录,让我把它放在这里:

始终有可能覆盖public function SearchForm() { return false; },因此删除表单。但是,这不会影响#filters-button(3.4)或侧边栏(3.0-3.3) 所以在这个时候,你必须使用CSS。

但我创建了一个Pull Request来实现$showSearchForm,它的工作方式与$showImportForm相同。

https://github.com/silverstripe/silverstripe-framework/pull/6237
https://github.com/silverstripe/silverstripe-framework/pull/6309(重新提出拉动请求)

这可能会合并到 3.4.2 3.5.0中,一旦你可以这样做:

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