sheadawson/quickaddnew 问题修复 & 功能扩展

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

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

sheadawson/quickaddnew

Composer 安装命令:

composer require sheadawson/quickaddnew

包简介

A decorator for form fields that manage object relationships, to allow adding a new object on the fly through a dialog window. It can handle has_one, has_many or many_many relationships. At the moment it has been tested / works on DropdownField and ListboxField. It works both in the CMS and in the f

README 文档

README

What is it?

A decorator for form fields that manage object relationships, to allow adding a new object on the fly through a dialog window. It can handle has_one,has_many or many_many relationships. At the moment it has been tested / works on DropdownField (and SearchableDropdownField), ListboxField and CheckboxSetField. It works both in the CMS and in the frontend.

screenshot

Requirements

SilverStripe 4/5

For SilverStripe, check branch 1.1

Usage

Firstly, when creating the form field, we need to create a closure that returns the source array to populate the field's options. We do this because later on, when the field is refreshed with the newly created Object ID as it's value, we need to use this function Again to get up to date data for the source.

$source = function(){
    return MyObject::get()->map()->toArray();
};

Then we can create the form field, calling the closure as the source argument

$field = DropdownField::create('MyObjectID', 'My Object', $source());
// or...
$field = ListboxField::create('MyObjects', 'My Objects', $source());
// or...
$field = CheckboxSetField::create('MyObjects', 'My Objects', $source());

Next, we can tell the field to use and configure quickaddnew with useAddNew.

  • The first parameter is the class name of the object that will be created.
  • The second is the $source closure
  • (optional) The third allows you to pass a specific set of fields to display in the dialog
  • (optional) The fourth allows you to pass a validator
  • (optional) The fifth allows you to specify if this is a frontend field

These allow you to customise the fields and required fields (for validation) for the dialog. By default the object class's getAddNewFields() or getCMSFields() methods are used

$field->useAddNew('MyObject', $source);
// or...
$field->useAddNew('MyObject', $source, $fields, $required, $isFrontend);

Add the field to your FieldList

$fields->addFieldToTab('Root.Main', $field);

统计信息

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

GitHub 信息

  • Stars: 41
  • Watchers: 6
  • Forks: 20
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2013-10-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固