simonwelsh / gridfieldrelationhandler
此包已被废弃,不再维护。未建议替代包。
此模块提供了两个GridField组件,有助于在SilverStripe中管理关系。
2.2.2
2015-07-14 17:48 UTC
Requires
- hhvm: ~3.6
Requires (Dev)
- 91carriage/phpunit-hhi: 4.5.*
- phpunit/phpunit: 4.5.*
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.