simonwelsh/gridfieldrelationhandler

此包已被废弃,不再维护。未建议替代包。

此模块提供了两个GridField组件,有助于在SilverStripe中管理关系。

安装: 6,318

依赖者: 0

建议者: 0

安全: 0

星星: 1,028

分支: 130

语言:Hack

类型:silverstripe-module

2.2.2 2015-07-14 17:48 UTC

This package is not auto-updated.

Last update: 2019-02-20 17:26:45 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.