symbiote/silverstripe-multirecordfield 问题修复 & 功能扩展

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

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

symbiote/silverstripe-multirecordfield

Composer 安装命令:

composer require symbiote/silverstripe-multirecordfield

包简介

A module for editing multiple records on a backend or frontend form.

README 文档

README

A drop-in replacement for GridField. Allows creating and editing multiple records in a backend or frontend form.

Supports

  • SilverStripe 3.2 and up
  • PHP 5.4+
  • Display Logic
  • Dropzone Module
  • Quick Add New Module

Example Use

class Page extends SiteTree {
    private static $has_many = array(
        'Cells'      => 'BasicContent',
    );

    public function getCMSFields()
    {
        $fields = parent::getCMSFields();

        $editor = MultiRecordField::create('ContentCellEditor', 'Content Cells', $this->Cells());
        $fields->addFieldToTab('Root.ContentCells', $editor);

        return $fields;
    }
}

MultiRecordField Nesting

The MultiRecordField supports nesting of other MultiRecordFields. When the field detects a MultiRecordField in the set of fields to edit, that field is added as another nested toggle field inside the parent set of fields for editing.

**Transform existing GridField into MultiRecordField **

You may want to retain a few configurations made to the GridField that MultiRecordField supports. In that case, you'll want to utilize the MultiRecordTransformation class.

This will ensure the properties on GridFieldExtensions GridFieldAddNewMultiClass will carry across.

<?php

foreach ($fields->dataFields() as $field) {
    if ($field instanceof GridField) {
        $fields->replaceField($field->getName(), $field->transform(new MultiRecordTransformation));
    }
}

Custom fields

The MultiRecordField uses the output of getCMSFields when building the fieldlist used for editing. To provide an alternate set of fields, define a getMultiRecordFields method that returns a FieldList object.

Additionally, the MultiRecordField calls the updateMultiEditFields extension hook on the record being edited to allow extensions a chance to change the fields.

Screenshots

Alt text

To-Do

Unit Tests Backend: - Ensure all form data is restored correctly when a Form $Validator returns false - Ensure Display Logic works cleanly with this module. - Ensure permission checking works as expected. Frontend: - Test sorting, ensure correct hidden fields are updated - Test add button and AJAX response. - Test error messages / display

Maintainers

Bugtracker

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固