承接 qingbing/pf-widgets-form-generator 相关项目开发

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

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

qingbing/pf-widgets-form-generator

Composer 安装命令:

composer require qingbing/pf-widgets-form-generator

包简介

渲染部件——form 表单构造器,分为表单选项和表单渲染

README 文档

README

描述

渲染部件——form 表单构造器,分为表单选项和表单渲染

注意事项

  • 该小部件基于"qingbing/php-html","qingbing/php-render"开发
  • 如果需要用到文件上传表单,需要引入"qingbing/php-upload"
  • 如果需要使用编辑器,需要引入"qingbing/php-kindeditor"("qingbing/php-assets-manager"会被同步引入)
  • 该部件定义的常量全部参考"\FormGenerator"
  • "\Abstracts\FormOption" 为表单定义基类
  • "\Widgets\FormGenerator" 为表单渲染类,如果要使用验证,需要手动拷贝并加载js包,参考"test/controllers/views/test/widget.php"

使用方法

1.1 表单选项定义示例

class TestForm extends FormOption
{
    /**
     * 定义的表单项目
     * @return mixed
     */
    public function getOptions()
    {
        return [
            [
                'code' => 'password',
                'label' => '设置密码',
                'input_type' => \FormGenerator::INPUT_TYPE_PASSWORD,
//                'data_type' => \FormGenerator::DATA_TYPE_PASSWORD, // default
                'allow_empty' => false,
            ],
            [
                'code' => 'comparePassword',
                'label' => '确认密码',
                'input_type' => \FormGenerator::INPUT_TYPE_PASSWORD,
                'data_type' => \FormGenerator::DATA_TYPE_COMPARE,
                'compare_field' => 'password',
                'allow_empty' => false,
            ],
            [
                'code' => 'sex',
                'label' => '性别',
                'input_type' => \FormGenerator::INPUT_TYPE_SELECT,
//                'data_type' => \FormGenerator::DATA_TYPE_SELECT, // default
                'input_data' => [
                    '10000' => '',
                    '10001' => '',
                    '10002' => '',
                ],
                'allow_empty' => false,
            ],
            [
                'code' => 'hobby',
                'label' => '爱好',
                'input_type' => \FormGenerator::INPUT_TYPE_SELECT,
                'data_type' => \FormGenerator::DATA_TYPE_CHOICE,
                'max' => 3,
                'min' => 2,
                'input_data' => [
                    '10001' => '跑步',
                    '10002' => '登山',
                    '10003' => '游泳',
                    '10004' => '写字',
                    '10005' => '唱歌',
                ],
                'allow_empty' => false,
            ],
            [
                'code' => 'checked',
                'label' => '是否同意',
                'input_type' => \FormGenerator::INPUT_TYPE_CHECKBOX, // 输入类型无需数据类型,最特殊的一个,其实隐藏为range
                'allow_empty' => false,
            ],
            [
                'code' => 'fruit',
                'label' => '水果',
                'input_type' => \FormGenerator::INPUT_TYPE_CHECKBOX_LIST,
//                'data_type' => \FormGenerator::DATA_TYPE_CHOICE, // 只有一种数据类型
                'min' => 2,
                'max' => 3,
                'input_data' => [
                    '10001' => '苹果',
                    '10002' => '桌子',
                    '10003' => '梨子',
                    '10004' => '香蕉',
                ],
                'allow_empty' => false,
            ],
            [
                'code' => 'avatar',
                'label' => '头像',
                'input_type' => \FormGenerator::INPUT_TYPE_FILE,
//                'data_type' => \FormGenerator::DATA_TYPE_FILE, // 只有一种数据类型
                'file_extensions' => 'jpg|jpeg|png',
                'allow_empty' => false,
            ],
            [
                'code' => 'lover',
                'label' => '最爱的水果',
                'input_type' => \FormGenerator::INPUT_TYPE_RADIO_LIST,
//                'data_type' => \FormGenerator::DATA_TYPE_CHECKED, // 只有一种数据类型
                'input_data' => [
                    '10001' => '苹果',
                    '10002' => '梨子',
                    '10003' => '香蕉',
                ],
                'allow_empty' => false,
            ],
            [
                'code' => 'content',
                'label' => '内容',
                'input_type' => \FormGenerator::INPUT_TYPE_EDITOR,
                'allow_empty' => false,
            ],
            [
                'code' => 'hidden',
                'label' => '隐藏域',
                'input_type' => \FormGenerator::INPUT_TYPE_HIDDEN,
                'data_type' => \FormGenerator::DATA_TYPE_STRING,
                'default' => "hide",
                'allow_empty' => false,
            ],
            [
                'code' => 'description',
                'label' => '描述',
                'input_type' => \FormGenerator::INPUT_TYPE_TEXTAREA,
                'data_type' => \FormGenerator::DATA_TYPE_STRING,
                'default' => "This is description",
                'allow_empty' => true,
            ],
            [
                'code' => 'required_field',
                'label' => '必填',
                'input_type' => \FormGenerator::INPUT_TYPE_TEXT,
                'data_type' => \FormGenerator::DATA_TYPE_REQUIRED,
            ],
            [
                'code' => 'email_field',
                'label' => '邮件',
                'input_type' => \FormGenerator::INPUT_TYPE_TEXT,
                'data_type' => \FormGenerator::DATA_TYPE_EMAIL,
                'allow_empty' => false,
            ],
            [
                'code' => 'url_field',
                'label' => 'URL',
                'input_type' => \FormGenerator::INPUT_TYPE_TEXT,
                'data_type' => \FormGenerator::DATA_TYPE_URL,
                'allow_empty' => false,
            ],
            [
                'code' => 'ip_field',
                'label' => 'IP地址',
                'input_type' => \FormGenerator::INPUT_TYPE_TEXT,
                'data_type' => \FormGenerator::DATA_TYPE_IP,
                'allow_empty' => false,
            ],
            [
                'code' => 'data_field',
                'label' => '日期',
                'input_type' => \FormGenerator::INPUT_TYPE_TEXT,
                'data_type' => \FormGenerator::DATA_TYPE_DATE,
                'allow_empty' => false,
            ],
            [
                'code' => 'phone_field',
                'label' => '宅电',
                'input_type' => \FormGenerator::INPUT_TYPE_TEXT,
                'data_type' => \FormGenerator::DATA_TYPE_PHONE,
                'allow_empty' => false,
            ],
            [
                'code' => 'fax_field',
                'label' => '传真号',
                'input_type' => \FormGenerator::INPUT_TYPE_TEXT,
                'data_type' => \FormGenerator::DATA_TYPE_FAX,
                'allow_empty' => false,
            ],
            [
                'code' => 'mobile_field',
                'label' => '手机',
                'input_type' => \FormGenerator::INPUT_TYPE_TEXT,
                'data_type' => \FormGenerator::DATA_TYPE_MOBILE,
                'allow_empty' => false,
            ],
            [
                'code' => 'contact_field',
                'label' => '联系人',
                'input_type' => \FormGenerator::INPUT_TYPE_TEXT,
                'data_type' => \FormGenerator::DATA_TYPE_CONTACT,
                'allow_empty' => false,
            ],
            [
                'code' => 'zip_field',
                'label' => '邮政编码',
                'input_type' => \FormGenerator::INPUT_TYPE_TEXT,
                'data_type' => \FormGenerator::DATA_TYPE_ZIP,
                'allow_empty' => false,
            ],
            [
                'code' => 'username_field',
                'label' => '用户名',
                'input_type' => \FormGenerator::INPUT_TYPE_TEXT,
                'data_type' => \FormGenerator::DATA_TYPE_USERNAME,
                'allow_empty' => false,
            ],
            [
                'code' => 'datetime_field',
                'label' => '时间',
                'input_type' => \FormGenerator::INPUT_TYPE_TEXT,
                'data_type' => \FormGenerator::DATA_TYPE_TIME,
                'allow_empty' => false,
            ],
            [
                'code' => 'password_field',
                'label' => '显示密码',
                'input_type' => \FormGenerator::INPUT_TYPE_TEXT,
                'data_type' => \FormGenerator::DATA_TYPE_PASSWORD,
                'allow_empty' => false,
            ],
            [
                'code' => 'compare_field',
                'label' => '确认密码',
                'input_type' => \FormGenerator::INPUT_TYPE_TEXT,
                'data_type' => \FormGenerator::DATA_TYPE_COMPARE,
                'compare_field' => 'password_field',
            ],
            [
                'code' => 'numeric_field',
                'label' => '数字',
                'input_type' => \FormGenerator::INPUT_TYPE_TEXT,
                'data_type' => \FormGenerator::DATA_TYPE_NUMERIC,
                'allow_empty' => false,
            ],
            [
                'code' => 'money_field',
                'label' => '货币',
                'input_type' => \FormGenerator::INPUT_TYPE_TEXT,
                'data_type' => \FormGenerator::DATA_TYPE_MONEY,
                'allow_empty' => false,
            ],
            [
                'code' => 'integer_field',
                'label' => '整数',
                'input_type' => \FormGenerator::INPUT_TYPE_TEXT,
                'data_type' => \FormGenerator::DATA_TYPE_INTEGER,
                'allow_empty' => false,
            ],
            [
                'code' => 'preg_field',
                'label' => '正则匹配',
                'input_type' => \FormGenerator::INPUT_TYPE_TEXT,
                'data_type' => \FormGenerator::DATA_TYPE_PREG,
                'pattern' => '/\d{2,4}/',
                'allow_empty' => false,
            ],
            [
                'code' => 'string_field',
                'label' => '字符串',
                'input_type' => \FormGenerator::INPUT_TYPE_TEXT,
                'data_type' => \FormGenerator::DATA_TYPE_STRING,
                'allow_empty' => false,
            ],
        ];
    }
}

1.2 组件表单渲染

<?php $this->widget('\Widgets\FormGenerator', [
    'model' => $model,
]); ?>

====== 异常代码集合 ======

异常代码格式:1029 - XXX - XX (组件编号 - 文件编号 - 代码内异常)

 - 102900101 : "{model}"无效属性"{attribute}"
 - 102900102 : 对比验证必须标记"compare_field"属性
 - 102900103 : 匹配验证必须指定"pattern"属性
 - 102900104 : 对比验证必须标记"compare_field"属性
 - 102900105 : 选择验证必须设置"input_data"属性
 - 102900106 : 选择验证"input_data"属性必须为数组
 - 102900107 : 多选验证必须设置"input_data"属性
 - 102900108 : 选择验证"input_data"属性必须为数组
 - 102900109 : 单选验证必须设置"input_data"属性
 - 102900110 : 选择验证"input_data"属性必须为数组
 
 - 102900201 : 无效的"\Widgets\FormGenerator"属性设置
 - 102900202 : 对比验证必须标记"compare_field"属性
 - 102900203 : 匹配验证必须指定"pattern"属性
 - 102900204 : 对比验证必须标记"compare_field"属性
 - 102900205 : 需要设置属性"input_data"
 - 102900206 : 属性"input_data"必须是数组

qingbing/pf-widgets-form-generator 适用场景与选型建议

qingbing/pf-widgets-form-generator 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 53 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 03 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 qingbing/pf-widgets-form-generator 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: JavaScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-03-19