承接 laravel-enso/formbuilder 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

laravel-enso/formbuilder

最新稳定版本:9.1.1

Composer 安装命令:

composer require laravel-enso/formbuilder

包简介

JSON-based form builder for Laravel Enso

README 文档

README

License Stable Downloads PHP Issues Merge Requests

Description

Forms is the JSON-based form builder used across Laravel Enso backends.

The package loads form templates from JSON, builds create and edit payloads around Eloquent models, computes actions and meta configuration, validates template structure, and ships test traits for common create/edit/destroy flows.

It is a backend payload builder, not a standalone UI package. The canonical frontend companion is @enso-ui/forms, which renders the payloads produced by this package.

Installation

Install the package:

composer require laravel-enso/forms

Optional publishes:

php artisan vendor:publish --tag=forms-config
php artisan vendor:publish --tag=forms-resources

Features

  • JSON template loading through Form.
  • Create and edit payload generation for Eloquent-backed forms.
  • Runtime mutation helpers for values, labels, options, visibility, readonly state, and route metadata.
  • Template validation for structure, actions, routes, and fields.
  • PHPUnit test traits for form workflows.
  • Direct integration with the Enso frontend form renderer and its field components.

Usage

Create or edit a form payload:

use LaravelEnso\Forms\Services\Form;

$form = new Form(__DIR__.'/Templates/example.json');

$createPayload = $form->create();
$editPayload = $form->edit($model);

Template structure

The JSON template must include at least:

  • method
  • sections
  • routeParams

The root template may also include:

  • title, icon
  • actions
  • authorize
  • autosave
  • clearErrorsControl
  • debounce
  • dividerTitlePlacement
  • labels
  • params
  • readonly
  • routePrefix
  • routes
  • tabs

Each section must define:

  • columns
  • fields

Optional section attributes are:

  • divider
  • title
  • column
  • tab
  • slot
  • hidden

Each field must define:

  • label
  • name
  • value
  • meta

Minimal template example

{
    "title": "Example",
    "icon": "user",
    "method": null,
    "routePrefix": "administration.users",
    "routeParams": {},
    "actions": ["store", "update", "destroy", "back"],
    "sections": [
        {
            "columns": 2,
            "title": "General",
            "fields": [
                {
                    "label": "Name",
                    "name": "name",
                    "value": "",
                    "meta": {
                        "type": "input",
                        "content": "text",
                        "custom": false
                    }
                },
                {
                    "label": "Roles",
                    "name": "roles",
                    "value": [],
                    "meta": {
                        "type": "select",
                        "multiple": true,
                        "source": "administration.roles.options",
                        "custom": false
                    }
                }
            ]
        }
    ]
}

Form service API

The LaravelEnso\Forms\Services\Form object is not just a loader. It is a fluent mutator for the template before create() or edit() finalizes the payload.

Common methods:

  • create(?Model $model = null)
  • edit(Model $model)
  • actions(...$actions)
  • routePrefix(string $prefix)
  • route(string $action, string $route)
  • routeParams(array $params)
  • title(string $title)
  • icon(string $icon)
  • append(string $param, mixed $value)
  • authorize(bool $authorize)
  • labels(bool $labels)

Field and section mutators:

  • label(string $field, string $value)
  • options(string $field, mixed $value)
  • value(string $field, mixed $value)
  • meta(string $field, string $param, mixed $value)
  • columns(string $section, int $value)
  • hide(...$fields) / show(...$fields)
  • disable(...$fields)
  • readonly(...$fields)
  • readonly() / readonly(bool $readonly)
  • hideSection(...$sections) / showSection(...$sections)
  • hideTab(...$tabs) / showTab(...$tabs)

Example:

use LaravelEnso\Forms\Services\Form;

$form = (new Form(app_path('Forms/Templates/users.json')))
    ->title('Edit User')
    ->icon('user')
    ->routePrefix('administration.users')
    ->append('locale', app()->getLocale())
    ->label('email', 'Login Email')
    ->options('role_id', $roles)
    ->value('is_active', true)
    ->readonly('email')
    ->readonly()
    ->hide('password')
    ->meta('phone', 'placeholder', '+40 700 000 000');

$payload = $form->edit($user);

Supported field types

The backend validator accepts these meta.type values:

  • input
  • select
  • datepicker
  • timepicker
  • textarea
  • password
  • wysiwyg

The frontend companion @enso-ui/forms currently renders these combinations:

  • input with content: text
  • input with content: number
  • input with content: email
  • input with content: password
  • input with content: encrypt
  • input with content: money
  • input with content: checkbox
  • select
  • textarea
  • datepicker
  • timepicker
  • wysiwyg

Important behavior:

  • encrypted inputs are returned as ************************ when the model already has a value
  • root readonly is preserved in the payload so the frontend can render the whole form without mutating actions
  • field-level meta.readonly remains available for locking individual fields
  • multi-select values are normalized to arrays of tracked keys
  • datepicker values are formatted with the configured or field-specific format
  • select source routes are converted to relative application paths
  • select fields that define enum class options are expanded through ::select() and default to translated labels
  • wysiwyg fields use TinyMCE by default and receive the configured TinyMCE API key automatically
  • wysiwyg fields may set editor: trix to use the Trix frontend editor instead

Supported meta keys

The validator accepts the following optional meta keys:

  • options, multiple, custom, content
  • step, min, max
  • disabled, readonly, hidden
  • source, format, altFormat, time
  • rows, placeholder
  • trackBy, label
  • tooltip, symbol, precision, thousand, decimal
  • positive, negative, zero
  • resize, translated
  • time12hr, disable-clear
  • objects, toolbar, plugins, editor, taggable
  • searchMode, params, pivotParams, customParams

Template validation rules

Validator runs four checks:

  • Structure: verifies root attributes, section format, columns, and tab consistency
  • Actions: only allows Enso form actions supported by the package
  • Routes: requires actual named routes for every action except back
  • Fields: verifies field attributes, checkbox values, select value shape, and delegates meta validation

Notable enforced rules:

  • create forms can use only back and store
  • update forms can use only back, create, show, update, and destroy
  • select fields must define options or source
  • checkbox fields must have boolean values
  • multi-select fields must receive array or object values
  • columns: custom requires an integer column per field

Enum-backed select fields may opt out of frontend label translation by setting "translated": false explicitly in the template.

Frontend companion

The canonical renderer is @enso-ui/forms.

Its public Vue components are:

  • EnsoForm
  • VueForm
  • CoreForm

The package integrates with companion UI packages such as:

  • @enso-ui/select
  • @enso-ui/datepicker
  • @enso-ui/wysiwyg
  • @enso-ui/money
  • @enso-ui/switch
  • @enso-ui/tabs

EnsoForm also exposes runtime helpers to the host application, including:

  • fetch()
  • submit()
  • field(name)
  • param(name)
  • routeParam(name)
  • fill(state)
  • setOriginal()
  • undo()
  • hideField(name) / showField(name)
  • hideTab(name) / showTab(name)

API

Services

  • LaravelEnso\\Forms\\Services\\Form
  • LaravelEnso\\Forms\\Services\\Builder
  • LaravelEnso\\Forms\\Services\\Validator

Published resources

  • config/enso/forms.php
  • app/Forms/Builders/ModelForm.php
  • app/Forms/Templates/template.php

Configuration highlights

  • validations
  • buttons
  • altDateFormat
  • selectPlaceholder
  • authorize
  • dividerTitlePlacement
  • labels
  • tinyMCEApiKey

Test traits

  • CreateForm
  • EditForm
  • DestroyForm

Depends On

Required Enso packages:

Companion frontend package:

Contributions

are welcome. Pull requests are great, but issues are good too.

Thank you to all the people who already contributed to Enso!

laravel-enso/formbuilder 适用场景与选型建议

laravel-enso/formbuilder 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 18.65k 次下载、GitHub Stars 达 123, 最近一次更新时间为 2017 年 08 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 laravel-enso/formbuilder 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 18.65k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 123
  • 点击次数: 15
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 123
  • Watchers: 10
  • Forks: 30
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-08-08