当前仓库属于暂停状态,部分功能使用受限,详情请查阅 仓库状态说明
1 Star 0 Fork 81

故人以 / form-builder
暂停

forked from xaboy / form-builder 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

form-builder

MIT xaboy version php version

PHP表单生成器,快速生成现代化的form表单。包含复选框、单选框、输入框、下拉选择框等元素以及,省市区三级联动,时间选择,日期选择,颜色选择,文件/图片上传等功能。

表单是使用form-create js表单生成器生成

如果对您有帮助,您可以点右上角 "Star" 支持一下 谢谢!

本项目还在不断开发完善中,如有建议或问题请在这里提出

安装

composer require xaboy/form-builder

示例

https://raw.githubusercontent.com/xaboy/form-builder/master/demo.jpg

各组件配置属性 点击查看

配置表单提交成功的回调

请在 config/config.php中配置formSuccessScript属性。设置为form提交成功后的js代码或js地址,重新window.formCreate.formSuccess方法(带<script>标签) 或者直接修改formScript.php

回调方法

    formCreate.formSuccess = function(res,$r) {
        //TODO 表单提交后的操作
    }

配置方法

[
    $form->setSuccessScript('<script src="collback.js"></script>');
    //OR
    $form->setSuccessScript('<script>
        formCreate.formSuccess = function(res,$r) {
            //TODO 表单提交后的操作
        }
    </script>');
]

代码


namespace Test;
use FormBuilder\Form;

//input组件
$input = Form::input('goods_name','商品名称');

//日期区间选择组件
$dateRange = Form::dateRange(
    'limit_time',
    '区间日期',
    strtotime('- 10 day'),
    time()
);

//省市二级联动组件
$cityArea = Form::city('address','收货地址',[
    '陕西省','西安市'
]);

$checkbox = Form::checkbox('label','表单',[])->options([
    ['value'=>'1','label'=>'好用','disabled'=>true],
    ['value'=>'2','label'=>'方便','disabled'=>true]
]);

//创建form
$form = Form::create('/save.php',[
    $input,$dateRange,$cityArea,$checkbox
]);

$html = $form->setMethod('get')->setTitle('编辑商品')->view();

//输出form页面
echo $html;

组件

namespace \FormBuilder\Form

  • Form::cascader 三级联动,value为array类型

  • Form::city 省市二级联动,value为array类型

  • Form::cityArea 省市区三级联动,value为array类型

  • Form::checkbox 复选框

  • Form::color 颜色选择

  • Form::date 日期选择

  • Form::dateRange 日期区间选择,value为array类型

  • Form::dateTime 日期+时间选择

  • Form::dateTimeRange 日期+时间 区间选择,value为array类型

  • Form::year 年份选择

  • Form::month 月份选择

  • Form::frame frame组件

  • Form::frameInputs frame组件,input类型,value为array类型

  • Form::frameFiles frame组件,file类型,value为array类型

  • Form::frameImages frame组件,image类型,value为array类型

  • Form::frameInputOne frame组件,input类型,value为string|number类型

  • Form::frameFileOne frame组件,file类型,value为string|number类型

  • Form::frameImageOne frame组件,image类型,value为string|number类型

  • Form::hidden hidden组件

  • Form::number 数字输入框

  • Form::input input输入框,其他type: text类型Form::text,password类型Form::password,textarea类型Form::textarea,url类型Form::url,email类型Form::email,date类型Form::idate

  • Form::radio 单选框

  • Form::rate 评分组件

  • Form::select select选择框

  • Form::selectMultiple select选择框,多选,value为array类型

  • Form::selectOne select选择框,单选

  • Form::slider 滑块组件

  • Form::sliderRange 滑块组件,区间选择,

  • Form::switches 开关组件

  • Form::timePicker

  • Form::time 时间选择组件

  • Form::timeRange 时间区间选择组件,value为array类型

  • Form::upload 上传组件

  • Form::uploadImages 多图上传组件,value为array类型

  • Form::uploadFiles 多文件上传组件,value为array类型

  • Form::uploadImageOne 单图上传组件

  • Form::uploadFileOne 单文件上传组件

select,checkbox,radio配置options

  • option($value, $label, $disabled = false) 单独设置选项
  • options(array $options, $disabled = false) 批量设置选项
  • setOptions($options, $disabled = false) 批量设置选项 支持匿名函数

输出

namespace \FormBuilder\Json

  • Json::succ(msg,data = []) 表单提交成功
  • Json::fail(errorMsg,data = []) 表单提交失败
  • Json::uploadSucc(filePath,msg) 文件/图片上传成功,上传成功后返回文件地址
  • Json::uploadFail(errorMsg) 文件/图片上传失败
MIT License Copyright (c) 2018 xaboy Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

PHP表单生成器,使用PHP快速生成现代化的form表单,包含复选框、单选框、输入框、下拉选择框等元素以及,省市区三级联动,时间选择,日期选择,颜色选择,文件/图片上传等功能。 展开 收起
PHP
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
PHP
1
https://gitee.com/peiyufei/form-builder.git
git@gitee.com:peiyufei/form-builder.git
peiyufei
form-builder
form-builder
master

搜索帮助