arillo/silverstripe-multiselectfield 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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+

field

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

GitHub 信息

  • Stars: 6
  • Watchers: 4
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2023-02-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固