toastnz/gridfieldrelationhandler

本模块提供了两个 GridField 组件,有助于管理 SilverStripe 内部的关系。

安装: 207

依赖: 0

建议者: 0

安全: 0

星星: 0

关注者: 3

分支: 19

类型:silverstripe-module

dev-master 2019-10-17 02:12 UTC

This package is auto-updated.

Last update: 2024-09-17 13:29:48 UTC


README

本模块提供了两个 GridField 组件,有助于管理 SilverStripe 内部的关系。 GridFieldHasOneRelationHandler 组件允许使用 SS_List 来选择 has_one 关系的值,而 GridFieldManyRelationHandler 组件则管理 RelationList

安装

如果您正在运行的 SilverStripe 版本早于 3.0.3,首先将 此补丁 应用到 GridFieldPaginator

下载此模块并将其解压到您网站的根目录中。通过访问 http://yoursite.com/?flush=1 来刷新您网站的清单。这些组件现在可以使用了。

GridFieldHasOneRelationHandler

GridFieldHasOneRelationHandler 组件提供单选按钮以选择 has_one 指向的对象。其构造函数接收存在关系的对象、关系名称以及一个可选的目标片段,该片段描述了保存关系按钮的位置。

示例

:::php
$config->addComponent(new GridFieldHasOneRelationHandler($this, 'MainImage'));

GridFieldManyRelationHandler

GridFieldManyRelationHandler 组件提供复选框以选择 has_many 或 many_many 指向的对象。其构造函数接收一个可选的目标片段,该片段描述了保存关系按钮的位置。

如果您的 GridField 也包含 GridFieldPaginator 组件,则此组件必须插入到它之前,以便正确地进行分页。

示例

:::php
// The second argument here ensures that this component is placed before any GridFieldPaginator
$config->addComponent(new GridFieldManyRelationHandler(), 'GridFieldPaginator');

许可证

Copyright (c) 2014, Simon Welsh - simon.geek.nz
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
    * The name of Simon Welsh may not be used to endorse or promote products
      derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.