i-lateral/silverstripe-fancy-form-scaffolder 问题修复 & 功能扩展

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

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

i-lateral/silverstripe-fancy-form-scaffolder

Composer 安装命令:

composer require i-lateral/silverstripe-fancy-form-scaffolder

包简介

Allows you to defined CMS form structure via config.yml

README 文档

README

The standard CMS Form Scaffolder does a good job of automatically creating forms to edit records in the SilverStripe admin, but if you want to create complex form layouts (adding fields to field groups, composite fields, custom tabs, etc) then you will have to spend a lot of time editing getCMSFields.

This module allows scaffolding of complex form layouts in the SilverStripe CMS via YML config. You can defined tabs, field types, field groupings and assotiations via some arrays in configuration.

Installing

You can install via composer:

composer require i-lateral/silverstripe-fancy-form-scaffolder

Usage

Once installed, simply add a cms_fields config variable to your DataObject and FormScaffolder will build all CMS forms (loaded using Form Scaffolding) for that object using the FormScaffolder.

Example Config

class Product extends DataObject
{
    private static $db = [
        'Name' => 'Varchar',
        'StockID' => 'Varchar',
        'Description' => 'HTMLText',
        'Price' => 'Currency',
        'ItemsPerCarton' => 'Int'
    ];

    private static $has_one = [
        'Supplier' => Factory::class
    ];

    private static $many_many = [
        'Categories' => Category::class
    ];

    private static $cms_fields = [
        'Root.Main' => [
            'fields' => [
                'ProductDetails' => 'h2',
                'Title/StockID' => [
                    'type' => \SilverStripe\Forms\FieldGroup::class,
                    'fields' => [
                        'Title',
                        'StockID'
                    ]
                ],
                'Description',
                'Price/Cartons' => [
                    'type' => 'SilverStripe\Forms\CompositeField',
                    'fields' => [
                        'BasePrice',
                        'ItemsPerCarton',
                        'SupplierID'
                    ]
                ]
            ]
        ],
        'Root.Components' => [
            'fields' => [
                'Additions'
            ]
        ]
    ];
}

Calling field methods on construction

You can also call field methods when the scaffolder constructs/retrieves the field.

This can be usefull for performing tasks, such as changing a field title or defining a number of columns on a CompositeField. You can do this using the following example:

'Title/StockID' => [
    'type' => \SilverStripe\Forms\CompositeField::class,
    'fields' => [
        'Title',
        'StockID'
    ],
    'methods' => [
        'setTitle' => '',
        'setColumnCount' => 2
    ]
]

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2020-05-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固