定制 dhensby/silverstripe-copybutton 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

dhensby/silverstripe-copybutton

Composer 安装命令:

composer require dhensby/silverstripe-copybutton

包简介

Adds copy button to the GridField.

README 文档

README

Adds a copy button to the GridField.

Requirements

  • SilverStripe ^6
  • PHP ^8.3

Installation

composer require dhensby/silverstripe-copybutton

Usage

To add the button to the GridField, add CopyButton as a component. The most common place to do this is in a ModelAdmin by overriding getEditForm():

use Unisolutions\GridField\CopyButton;

public function getEditForm($id = null, $fields = null)
{
    $form = parent::getEditForm($id, $fields);

    $form
        ->Fields()
        ->fieldByName($this->sanitiseClassName($this->modelClass))
        ->getConfig()
        ->addComponent(new CopyButton(), GridFieldEditButton::class);

    return $form;
}

Display modes

By default the copy button appears in the action menu dropdown for each row. Pass true to the constructor to render it as a standalone column button instead:

->addComponent(new CopyButton(true));

Cascading duplications

The copy action makes an exact duplicate of the record. To also duplicate relations, configure cascading duplications on your DataObject:

See: https://docs.silverstripe.org/en/6/developer_guides/model/relations/#cascading-duplications

Post-copy hook

To run custom logic after a record is copied (e.g. clearing certain relations), implement onAfterDuplicate() on the DataObject or an extension:

class MyDataObjectExtension extends DataExtension
{
    public function onAfterDuplicate(DataObject $original, bool $doWrite): void
    {
        // e.g. clear a relation on the new copy
        $this->owner->Tags()->removeAll();
    }
}

Maintainer

Originally authored by Elvinas Liutkevičius elvinas@unisolutions.eu.
Currently maintained by dhensby.

License

BSD — see silverstripe.org/BSD-license

统计信息

  • 总下载量: 8.15k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 20
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2018-03-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固