arillo/silverstripe-multiselectfield
最新稳定版本:2.0.2
Composer 安装命令:
composer require arillo/silverstripe-multiselectfield
包简介
A sortable multiple select field for managing many-to-many relations
README 文档
README
A drag & drop sortable select field for managing many-to-many relations.
Inspired by https://github.com/kinglozzer/silverstripe-multiselectfield which breaks in SilverStripe 4.12+
Installation:
Composer:
$ composer require arillo/silverstripe-multiselectfield
Download:
Simply clone or download this repository and put it in a folder called 'multiselectfield' in your SilverStripe installation folder, then run dev/build.
Example:
The field currently only supports many-to-many relations. The constructor requires an argument for a field to sort on, which you need to define in your $many_many_extraFields.
The following is an example of how to use MultiSelectField in a simple many-to-many relationship with a "Sort" extra field:
use Arillo\MultiSelectField\MultiSelectField; class Department extends DataObject { private static $db = [ 'Name' => 'Varchar', ]; private static $many_many = [ 'StaffMembers' => 'StaffMember', ]; private static $many_many_extraFields = [ 'StaffMembers' => [ 'Sort' => 'Int', ], ]; /** * @return FieldList */ public function getCMSFields() { $fields = parent::getCMSFields(); $staffField = MultiSelectField::create( 'StaffMembers', 'Staff members', $this, 'Sort' ); $fields->addFieldToTab('Root.Main', $staffField); return $fields; } }
class StaffMember extends DataObject { private static $db = [ 'Name' => 'Varchar', ]; private static $many_many = [ 'Departments' => 'Department', ]; }
统计信息
- 总下载量: 1.78k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2023-02-15
