定制 briceburg/silverstripe-flexiform 二次开发

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

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

briceburg/silverstripe-flexiform

Composer 安装命令:

composer require briceburg/silverstripe-flexiform

包简介

Add CMS configurable forms to your SilverStripe objects.

README 文档

README

Add CMS configurable forms to your SilverStripe objects.

Features

  • Add forms to any DataObject or Page
  • GridField based management of fields, options, submissions, actions, &c.
  • Programmatically define initial fields and handlers + build them from the Environment Builder
  • Many-many between Form and FlexiFormField, has_many between FlexiFormHandler
    • reduced repetitiveness and improved consistency
    • extraFields allows per-form customization without disturbing other forms using the same field
  • Protection against form re-submissions
  • Definable, friendly post URLs for logs and analytics
  • Support for multiple forms per page

Requirements

The venerable GridFieldExtensions https://github.com/ajshort/silverstripe-gridfieldextensions

Tested in SilverStripe 3.1

Screenshots

flexiform fields

field editing

Usage

  • Add flexiforms to Pages and DataObjects by extending with FlexiFormExtension. E.g.
class Event extends DataObject
{

    private static $extensions = array(
        'FlexiFormExtension'
    );

}

Trigger the environment builder (/dev/build) after extending objects -- You will now see the Form tab when editing Event in the CMS.

  • To display flexiforms, add $FlexiForm to your template. Here's a sample Event.ss;
<div class="event-content">
  <% if not FlexiFormPosted %>
    $Content
  <% end_if %>
   
  $FlexiForm    
</div>

Here we use $FlexiFormPosted to hide $Content if a form has been posted.

Flexiform also provides a convenience wrapper around the standard $Form method. Calling $Form from a Page extended by FlexiFormExtension will output the associated flexiform. E.g.

<div class="event-content">
  <% if not FlexiFormPosted %>
    $Content
  <% end_if %>
   
  $Form    
</div>

Works exactly the same as the first example.

Form Identifiers

Use Form Identifiers when you have multiple forms on a page, need to reference a form (e.g from another page), or want to control the post URL.

FlexiForm extends ContentController to provide the $FlexiForm method to all pages. By default it expects the controller's dataRecord to be an object extended by FlexiFormExtension. You can explicitly set the flexiform object by calling the setFlexiFormObject method on your controller, or by passing an Identifer to $FlexiForm.

Form Identifiers are defined in the Settings tab on flexiforms. The identifier is also used in post URLs for easy tacking of form submissions in server logs and analytics.

<!-- .ss template -->

<div class="page-content">
  $FlexiForm('newsletter_form')    
</div>

Shortcodes

Alternately, you can use the [flexiform] shortcode in content areas. This is especially useful for controlling placement of a form inside existing content.

Optionally pass a Form Identifier through the ID paramater.

Some WYSIWYG Content

Default Form: <br /> [FlexiForm]

Explicit Form: <br /> [flexiform id=registration_form]

Templates, Custom Form Classes

By default, flexiform uses Form.ss to render the form. You can change the template by

  • Simple Means: Adding a FlexiForm.ss to your theme

  • Powerful Means: Provide an alternate form class via $flexiform_form_class

class Event extends DataObject
{
    private static $extensions = array(
        'FlexiFormExtension'
    );
    
    private static $flexi_form_class = 'EventForm';

}

// attempts to use EventForm.ss by default, falling back to Form.ss 
class EventForm extends FlexiForm {
    
    // optional: provide a specific template
    // public function getTemplate() { return 'EventSpecificTemplate'; } 
}

Configuration

Most configuration is accomplished through the CMS -- however you can further tailor behavior through subclassing (protected properties, getters, and setters) and YAML Configuration.

See docs/CONFIGURATION.md for documentation and examples.

briceburg/silverstripe-flexiform 适用场景与选型建议

briceburg/silverstripe-flexiform 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 124 次下载、GitHub Stars 达 17, 最近一次更新时间为 2014 年 12 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「form」 「cms」 「sortable」 「manage」 「silverstripe」 「userforms」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 briceburg/silverstripe-flexiform 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 briceburg/silverstripe-flexiform 我们能提供哪些服务?
定制开发 / 二次开发

基于 briceburg/silverstripe-flexiform 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 17
  • Watchers: 4
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2014-12-02