定制 fullscreeninteractive/silverstripe-manyfield 二次开发

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

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

fullscreeninteractive/silverstripe-manyfield

Composer 安装命令:

composer require fullscreeninteractive/silverstripe-manyfield

包简介

SilverStripe FormField for adding dynamic data to forms.

README 文档

README

Version License CI

A reusable approach to a form field which allows you to create and delete rows in either custom built forms or in Userforms.

This is designed to work on the front-end with limited javascript (i.e it does not require GridField or entwine).

Each row can relate to a DataObject subclass or simply to be used to capture the data as an array.

Installation

composer require fullscreeninteractive/silverstripe-manyfield

Supports Silverstripe CMS ^6.

Development

Install development dependencies:

composer install

Run static analysis:

composer lint

Run tests:

composer test

Usage

Image of Function

use FullscreenInteractive\ManyField\ManyField;

$fields = new FieldList(
    $many = ManyField::create('SwabList', [
        TextField::create('Swab'),
        TextField::create('TestSite'),
        TextField::create('Description'),
        TextField::create('Material')
    ])
);

Data will either be saved as setSwabList($data), SwabList database field or in the SwabList relation. If you are saving into a relation such as HasMany or ManyMany list then make sure you include a hidden field in your field list.

    $many = ManyField::create('SwabList', [
        HiddenField::create('ID', ''),
        TextField::create('Swab'),
        TextField::create('TestSite'),
        TextField::create('Description'),
        TextField::create('Material')
    ]);

Sorting

Include a Hidden field Sort and make sure sorting is enabled.

    $many = ManyField::create('SwabList', [
        HiddenField::create('ID', ''),
        HiddenField::create('Sort', ''),
        TextField::create('TestSite')
    ])->setCanSort(true);

Required Fields

$many = ManyField::create('SwabList', [
    TextField::create('TestSite')->setRequired(true)
])->setCanSort(true);

Javascript Events

If you have UI handlers that need to run when fields are added or removed (such as Date Pickers) create a handler on your <body> element and listen for either:

  • manyFieldAdded
  • manyFieldRemoved

FAQ

When I use this with File fields I don't get files uploaded?

Make sure your form encoding is set to the correct MIME type.

$form->setEncType(Form::ENC_TYPE_MULTIPART);

Licence

BSD 3-Clause License

统计信息

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

GitHub 信息

  • Stars: 7
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2018-07-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固