Browse Source

1.2.0版本

xaboy 7 years ago
parent
commit
7a85f0fc02

+ 24 - 0
document/Cascader.php

@@ -0,0 +1,24 @@
+<?php
+/**
+ * FormBuilder表单生成器
+ * Author: xaboy
+ * Github: https://github.com/xaboy/form-builder
+ */
+
+/**
+ * Cascader组件方法说明
+ * 方法 返回值 方法名(参数) 注释
+ * @method $this disabled(Boolean $bool) 是否禁用选择器
+ * @method $this clearable(Boolean $bool) 是否支持清除
+ * @method $this placeholder(String $placeholder)
+ * @method $this trigger(String $trigger) 次级菜单展开方式,可选值为 click 或 hover
+ * @method $this changeOnSelect(Boolean $bool) 当此项为 true 时,点选每级菜单选项值都会发生变化, 默认为 false
+ * @method $this size(String $size) 输入框大小,可选值为large和small或者不填
+ * @method $this filterable(Boolean $bool) 是否支持搜索
+ * @method $this notFoundText(String $text)
+ * @method $this transfer(Boolean $bool) /是否将弹层放置于 body 内,在 Tabs、带有 fixed 的 Table 列内使用时,建议添加此属性,它将不受父级样式影响,从而达到更好的效果
+ * @method $this required($message = null, $trigger = 'change') 设置为必选项
+ * @method $this value($value) 设置value
+ */
+
+$cascader = \FormBuilder\Form::cityArea('address','省市区三级联动','陕西省','西安市','新城区')->clearable(true);

+ 34 - 0
document/Checkbox.php

@@ -0,0 +1,34 @@
+<?php
+/**
+ * FormBuilder表单生成器
+ * Author: xaboy
+ * Github: https://github.com/xaboy/form-builder
+ */
+
+/**
+ * Cascader 多级联动组件方法说明
+ * 方法 返回值 方法名(参数) 注释
+ * @method $this type(String $type) 数据类型, 支持 city_area(省市区三级联动), city (省市二级联动), other (自定义)
+ * @method $this data(Array $data) 可选项的数据源,
+ * 三级数据结构示例:{
+ *       "value":"陕西省", "label":"陕西省", "children":[{
+ *           "value":"西安市", "label":"西安市", "children":[{
+ *              "value":"高新区", "label":"高新区"
+ *          }]
+ *       }]
+ *  }
+ * @method $this disabled(Boolean $bool) 是否禁用选择器
+ * @method $this clearable(Boolean $bool) 是否支持清除
+ * @method $this placeholder(String $placeholder)
+ * @method $this trigger(String $trigger) 次级菜单展开方式,可选值为 click 或 hover
+ * @method $this changeOnSelect(Boolean $bool) 当此项为 true 时,点选每级菜单选项值都会发生变化, 默认为 false
+ * @method $this size(String $size) 输入框大小,可选值为large和small或者不填
+ * @method $this filterable(Boolean $bool) 是否支持搜索
+ * @method $this notFoundText(String $text)
+ * @method $this transfer(Boolean $bool) /是否将弹层放置于 body 内,在 Tabs、带有 fixed 的 Table 列内使用时,建议添加此属性,它将不受父级样式影响,从而达到更好的效果
+ * @method $this required($message = null, $trigger = 'change') 设置为必选项
+ * @method $this value($value) 设置value
+ * @method string getType() 获取组件类型 city省市二级联动,city_area省市区三级联动,other其他(默认)
+ */
+
+$cascader = \FormBuilder\Form::cityArea('address','省市区三级联动','陕西省','西安市','新城区')->clearable(true);

+ 24 - 0
document/ColorPicker.php

@@ -0,0 +1,24 @@
+<?php
+/**
+ * FormBuilder表单生成器
+ * Author: xaboy
+ * Github: https://github.com/xaboy/form-builder
+ */
+
+/**
+ * Checkbox 单选框组件方法说明
+ * 方法 返回值 方法名(参数) 注释
+ * @method $this size(String $size) 多选框组的尺寸,可选值为 large、small、default 或者不设置
+ * @method $this required($message = null, $trigger = 'change') 设置为必选项
+ * @method $this value($value) 设置value
+ */
+
+//单选框
+$checkbox = \FormBuilder\Form::checkbox('is_show','是否显示',1)->options([
+    ['label'=>'显示','value'=>1,'disabled'=>false],
+    ['label'=>'隐藏','value'=>0,'disabled'=>false]
+]);
+
+$checkbox = \FormBuilder\Form::checkbox('is_show','是否显示',1)
+    ->option(1,'显示',false)
+    ->option(0,'隐藏',false);

+ 23 - 0
document/DatePicker.php

@@ -0,0 +1,23 @@
+<?php
+/**
+ * FormBuilder表单生成器
+ * Author: xaboy
+ * Github: https://github.com/xaboy/form-builder
+ */
+
+/**
+ * ColorPicker 颜色选择器组件方法说明
+ * 方法 返回值 方法名(参数) 注释
+ * @method $this disabled(Boolean $bool) 是否禁用
+ * @method $this alpha(Boolean $bool) 是否支持透明度选择, 默认为false
+ * @method $this hue(Boolean $bool) 是否支持色彩选择, 默认为true
+ * @method $this recommend(Boolean $bool) 是否显示推荐的颜色预设, 默认为false
+ * @method $this size(String $size) 尺寸,可选值为large、small、default或者不设置
+ * @method $this format(String $format) 颜色的格式,可选值为 hsl、hsv、hex、rgb    String    开启 alpha 时为 rgb,其它为 hex
+ * @method $this colors(array $colors) 自定义颜色预设
+ * @method $this required($message = null, $trigger = 'change') 设置为必选项
+ * @method $this value($value) 设置value
+ */
+
+//颜色选择器组件
+$colorPicker = \FormBuilder\Form::color('color','选择颜色','#FF7271');

+ 34 - 0
document/Frame.php

@@ -0,0 +1,34 @@
+<?php
+/**
+ * FormBuilder表单生成器
+ * Author: xaboy
+ * Github: https://github.com/xaboy/form-builder
+ */
+
+/**
+ * DatePicker 日期组件方法说明
+ * 方法 返回值 方法名(参数) 注释
+ * @method $this type(String $type) 显示类型,可选值为 date、daterange、datetime、datetimerange、year、month
+ * @method $this format(String $format) 展示的日期格式, 默认为yyyy-MM-dd HH:mm:ss
+ * @method $this placement(String $placement) 日期选择器出现的位置,可选值为top, top-start, top-end, bottom, bottom-start, bottom-end, left, left-start, left-end, right, right-start, right-end, 默认为bottom-start
+ * @method $this placeholder(String $placeholder) 占位文本
+ * @method $this confirm(Boolean $bool) 是否显示底部控制栏,开启后,选择完日期,选择器不会主动关闭,需用户确认后才可关闭, 默认为false
+ * @method $this size(String $size) 尺寸,可选值为large、small、default或者不设置
+ * @method $this disabled(Boolean $bool) 是否禁用选择器
+ * @method $this clearable(Boolean $bool) 是否显示清除按钮
+ * @method $this readonly(Boolean $bool) 完全只读,开启后不会弹出选择器,只在没有设置 open 属性下生效
+ * @method $this editable(Boolean $bool) 文本框是否可以输入, 默认为false
+ * @method $this transfer(Boolean $bool) 是否将弹层放置于 body 内,在 Tabs、带有 fixed 的 Table 列内使用时,建议添加此属性,它将不受父级样式影响,从而达到更好的效果, 默认为false
+ * @method $this splitPanels(Boolean $bool) 开启后,左右面板不联动,仅在 daterange 和 datetimerange 下可用。
+ * @method $this showWeekNumbers(Boolean $bool) 开启后,可以显示星期数。
+ * @method $this value($value) 设置value
+ */
+
+//日期选择
+$date = \FormBuilder\Form::date('date','日期选择',time());
+//日期区间选择
+$dateRange = \FormBuilder\Form::dateRange('dateRange','日期区间选择',time(),strtotime('+ 1 day'));
+//日期+时间选择
+$dateTime = \FormBuilder\Form::dateTime('dateTime','日期+时间选择',time());
+//日期+时间区间选择
+$dateTimeRange = \FormBuilder\Form::dateTimeRange('dateTimeRange','日期+时间区间选择',time(),strtotime('+ 1 day'));

+ 35 - 0
document/Hidden.php

@@ -0,0 +1,35 @@
+<?php
+/**
+ * FormBuilder表单生成器
+ * Author: xaboy
+ * Github: https://github.com/xaboy/form-builder
+ */
+
+/**
+ * Frame 框架组件方法说明
+ * 方法 返回值 方法名(参数) 注释
+ * @method $this type(String $type) frame类型, 有input, file, image, 默认为input
+ * @method $this src(String $src) iframe地址
+ * @method $this maxLength(int $length) value的最大数量, 默认无限制
+ * @method $this icon(String $icon) 打开弹出框的按钮图标
+ * @method $this height(String $height) 弹出框高度
+ * @method $this width(String $width) 弹出框宽度
+ * @method $this spin(Boolean $bool) 是否显示加载动画, 默认为 true
+ * @method $this frameTitle(String $title) 弹出框标题
+ * @method $this handleIcon(Boolean $bool) 操作按钮的图标, 设置为false将不显示, 设置为true为默认的预览图标, 类型为file时默认为false, image类型默认为true
+ * @method $this allowRemove(Boolean $bool) 是否可删除, 设置为false是不显示删除按钮
+ * @method $this value($value) 设置value
+ */
+
+//多个图片选择
+$frameImages = \FormBuilder\Form::frameImages('images','图片选择',[]);
+//多个文件选择
+$frameFiles = \FormBuilder\Form::frameFiles('files','文件选择',[]);
+//多个图标选择,用','隔开
+$frameInputs = \FormBuilder\Form::frameInputs('inputs','图标选择',[]);
+//单个图片选择
+$frameFileOne = \FormBuilder\Form::frameFileOne('images','图片选择','');
+//单个文件选择
+$frameFileOne = \FormBuilder\Form::frameFileOne('files','文件选择','');
+//单个图标选择
+$frameFileOne = \FormBuilder\Form::frameFileOne('inputs','图标选择','');

+ 14 - 0
document/Input.php

@@ -0,0 +1,14 @@
+<?php
+/**
+ * FormBuilder表单生成器
+ * Author: xaboy
+ * Github: https://github.com/xaboy/form-builder
+ */
+
+/**
+ * Hidden Hidden组件方法说明
+ * 方法 返回值 方法名(参数) 注释
+ * @method $this value($value) 设置value
+ */
+
+$hidden = \FormBuilder\Form::hidden("id",1);

+ 35 - 0
document/InputNumber.php

@@ -0,0 +1,35 @@
+<?php
+/**
+ * FormBuilder表单生成器
+ * Author: xaboy
+ * Github: https://github.com/xaboy/form-builder
+ */
+
+/**
+ * Input Input组件方法说明
+ * 方法 返回值 方法名(参数) 注释
+ * @method $this type(String $type) 输入框类型,可选值为 text、password、textarea、url、email、date;
+ * @method $this size(String $size) 输入框尺寸,可选值为large、small、default或者不设置;
+ * @method $this placeholder(String $placeholder) 占位文本
+ * @method $this clearable(Boolean $bool) 是否显示清空按钮, 默认为false
+ * @method $this disabled(Boolean $bool) 设置输入框为禁用状态, 默认为false
+ * @method $this readonly(Boolean $bool) 设置输入框为只读, 默认为false
+ * @method $this maxlength(int $length) 最大输入长度
+ * @method $this icon(String $icon) 输入框尾部图标,仅在 text 类型下有效
+ * @method $this rows(int $rows) 文本域默认行数,仅在 textarea 类型下有效, 默认为2
+ * @method $this number(Boolean $bool) 将用户的输入转换为 Number 类型, 默认为false
+ * @method $this autofocus(Boolean $bool) 自动获取焦点, 默认为false
+ * @method $this autocomplete(Boolean $bool) 原生的自动完成功能, 默认为false
+ * @method $this spellcheck(Boolean $bool) 原生的 spellcheck 属性, 默认为false
+ * @method $this wrap(String $warp) 原生的 wrap 属性,可选值为 hard 和 soft, 默认为soft
+ * @method $this autoSize(Number $minRows, Number $maxRows) 自适应内容高度,仅在 textarea 类型下有效
+ * @method $this required($message = null, $trigger = 'blur') 组件的值为必填
+ * @method $this value($value) 设置value
+ */
+
+$text = \FormBuilder\Form::text('goods_name','商品名称');
+$password = \FormBuilder\Form::password('password','密码');
+$textarea = \FormBuilder\Form::textarea('textarea','简介');
+$url = \FormBuilder\Form::url('url','链接');
+$email = \FormBuilder\Form::email('email','邮箱');
+$idate = \FormBuilder\Form::idate('idate','日期');

+ 23 - 0
document/Radio.php

@@ -0,0 +1,23 @@
+<?php
+/**
+ * FormBuilder表单生成器
+ * Author: xaboy
+ * Github: https://github.com/xaboy/form-builder
+ */
+
+/**
+ * InputNumber 数字输入框组件方法说明
+ * 方法 返回值 方法名(参数) 注释
+ * @method $this max(float $max) 最大值
+ * @method $this min(float $min) 最小值
+ * @method $this step(float $step) 每次改变的步伐,可以是小数
+ * @method $this size(String $size) 输入框尺寸,可选值为large、small、default或者不填
+ * @method $this disabled(Boolean $bool) 设置禁用状态,默认为false
+ * @method $this placeholder(String $placeholder) 占位文本
+ * @method $this readonly(Boolean $bool) 是否设置为只读,默认为false
+ * @method $this editable(Boolean $bool) 是否可编辑,默认为true
+ * @method $this precision(int $precision) 数值精度
+ * @method $this value($value) 设置value
+ */
+
+$number = \FormBuilder\Form::number('sort','排序',1);

+ 3 - 1
src/Form.php

@@ -23,6 +23,7 @@ use FormBuilder\traits\form\FormSliderTrait;
 use FormBuilder\traits\form\FormSwitchesTrait;
 use FormBuilder\traits\form\FormTimePickerTrait;
 use FormBuilder\traits\form\FormUploadTrait;
+use FormBuilder\traits\form\FormOptionTrait;
 
 class Form
 {
@@ -40,7 +41,8 @@ class Form
         FormSliderTrait,
         FormCascaderTrait,
         FormHiddenTrait,
-        FormTimePickerTrait;
+        FormTimePickerTrait,
+        FormOptionTrait;
 
     /**
      * 三级联动 加载省市数据

+ 1 - 1
src/components/Frame.php

@@ -15,7 +15,7 @@ use FormBuilder\Helper;
  * 框架组件
  * Class Frame
  * @package FormBuilder\components
- * @method $this type(String $type) rame类型, 有input, file, image, 默认为input
+ * @method $this type(String $type) frame类型, 有input, file, image, 默认为input
  * @method $this src(String $src) iframe地址
  * @method $this maxLength(int $length) value的最大数量, 默认无限制
  * @method $this icon(String $icon) 打开弹出框的按钮图标

+ 2 - 0
src/traits/component/ComponentOptionsTrait.php

@@ -19,10 +19,12 @@ trait ComponentOptionsTrait
      * @param $value
      * @param $label
      * @param bool $disabled
+     * @return $this
      */
     public function option($value, $label, $disabled = false)
     {
         $this->options[] = new Option($value, $label, $disabled);
+        return $this;
     }
 
 

+ 19 - 0
src/traits/form/FormOptionTrait.php

@@ -0,0 +1,19 @@
+<?php
+/**
+ * FormBuilder表单生成器
+ * Author: xaboy
+ * Github: https://github.com/xaboy/form-builder
+ */
+
+namespace FormBuilder\traits\form;
+
+
+use FormBuilder\components\Option;
+
+trait FormOptionTrait
+{
+    public static function option($value, $label = '', $disabled = false)
+    {
+        return new Option($value,$label,$disabled);
+    }
+}