【问题标题】:SilverStripe remove ModelAdmin searchSilverStripe 移除 ModelAdmin 搜索
【发布时间】:2016-10-26 09:49:53
【问题描述】:

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

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

#filters-button {
    display: none;
}

【问题讨论】:

    标签: php silverstripe


    【解决方案1】:

    我们在 IRC 上进行了讨论,但为了记录,让我把它放在这里:

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

    然而,我刚刚创建了一个拉取请求来实现$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'];
    }
    

    【讨论】:

    • 今天 3.5.0-rc2(候选发布 2)已被标记,我的拉取请求已及时合并。所以它会在 3.5 中出现一次,可能会在接下来的几周内发布。如果您在 composer 中只需要“~3.5”(等于 >=3.5,
    猜你喜欢
    • 2021-04-14
    • 2017-09-30
    • 1970-01-01
    • 2020-03-24
    • 2023-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多