|
|
@@ -18,8 +18,6 @@ PHP表单生成器,快速生成现代化的form表单。包含复选框、单
|
|
|
</p>
|
|
|
|
|
|
|
|
|
-#### 表单是使用[form-create](https://github.com/xaboy/form-create) js表单生成器生成
|
|
|
-
|
|
|
#### 如果对您有帮助,您可以点右上角 "Star" 支持一下 谢谢!
|
|
|
|
|
|
#### 本项目还在不断开发完善中,如有建议或问题请[在这里提出](https://github.com/xaboy/form-builder/issues/new)
|
|
|
@@ -33,6 +31,78 @@ PHP表单生成器,快速生成现代化的form表单。包含复选框、单
|
|
|

|
|
|
|
|
|
|
|
|
+### 例子 (TP框架)
|
|
|
+
|
|
|
+#### 版本1 编辑权限
|
|
|
+```php
|
|
|
+$form = Form::create(Url::build('update',array('id'=>$id)),[
|
|
|
+ Form::input('menu_name','按钮名称',$menu['menu_name']),
|
|
|
+ Form::select('pid','父级id',(string)$menu->getData('pid'))->setOptions(function()use($id){
|
|
|
+ $list = (Util::sortListTier(MenusModel::where('id','<>',$id)->select()->toArray(),'顶级','pid','menu_name'));
|
|
|
+ $menus = [['value'=>0,'label'=>'顶级按钮']];
|
|
|
+ foreach ($list as $menu){
|
|
|
+ $menus[] = ['value'=>$menu['id'],'label'=>$menu['html'].$menu['menu_name']];
|
|
|
+ }
|
|
|
+ return $menus;
|
|
|
+ })->filterable(1),
|
|
|
+ Form::select('module','模块名',$menu['module'])->options([['label'=>'总后台','value'=>'admin'],['label'=>'总后台1','value'=>'admin1']]),
|
|
|
+ Form::input('controller','控制器名',$menu['controller']),
|
|
|
+ Form::input('action','方法名',$menu['action']),
|
|
|
+ Form::input('params','参数',MenusModel::paramStr($menu['params']))->placeholder('举例:a/123/b/234'),
|
|
|
+ Form::frameInputOne('icon','图标',Url::build('admin/widget.widgets/icon',array('fodder'=>'icon')),$menu['icon'])->icon('ionic'),
|
|
|
+ Form::number('sort','排序',$menu['sort']),
|
|
|
+ Form::radio('is_show','是否菜单',$menu['is_show'])->options([['value'=>0,'label'=>'隐藏'],['value'=>1,'label'=>'显示(菜单只显示三级)']])
|
|
|
+ ]);
|
|
|
+$form->setMethod('post')->setTitle('编辑权限');
|
|
|
+$this->assign(compact('form'));
|
|
|
+return $this->fetch('public/form-builder');
|
|
|
+
|
|
|
+```
|
|
|
+#### 效果
|
|
|
+
|
|
|
+
|
|
|
+#### 版本2 添加产品
|
|
|
+```php
|
|
|
+$field = [
|
|
|
+ Form::select('cate_id','产品分类')->setOptions(function(){
|
|
|
+ $list = CategoryModel::getTierList();
|
|
|
+ foreach ($list as $menu){
|
|
|
+ $menus[] = ['value'=>$menu['id'],'label'=>$menu['html'].$menu['cate_name'],'disabled'=>$menu['pid']== 0];//,'disabled'=>$menu['pid']== 0];
|
|
|
+ }
|
|
|
+ return $menus;
|
|
|
+ })->filterable(1)->multiple(1),
|
|
|
+ Form::input('store_name','产品名称')->col(Form::col(8)),
|
|
|
+ Form::input('store_info','产品简介')->type('textarea'),
|
|
|
+ Form::input('keyword','产品关键字')->placeholder('多个用英文状态下的逗号隔开'),
|
|
|
+ Form::input('unit_name','产品单位','件'),
|
|
|
+ Form::frameImageOne('image','产品主图片(305*305px)',Url::build('admin/widget.images/index',array('fodder'=>'image')))->icon('image')->width('100%')->height('550px'),
|
|
|
+ Form::frameImages('slider_image','产品轮播图(640*640px)',Url::build('admin/widget.images/index',array('fodder'=>'slider_image')))->maxLength(5)->icon('images')->width('100%')->height('550px')->spin(0),
|
|
|
+ Form::number('price','产品售价')->min(0)->col(8),
|
|
|
+ Form::number('ot_price','产品市场价')->min(0)->col(8),
|
|
|
+ Form::number('give_integral','赠送积分')->min(0)->precision(0)->col(8),
|
|
|
+ Form::number('postage','邮费')->min(0)->col(Form::col(8)),
|
|
|
+ Form::number('sales','销量')->min(0)->precision(0)->col(8),
|
|
|
+ Form::number('ficti','虚拟销量')->min(0)->precision(0)->col(8),
|
|
|
+ Form::number('stock','库存')->min(0)->precision(0)->col(8),
|
|
|
+ Form::number('cost','产品成本价')->min(0)->col(8),
|
|
|
+ Form::number('sort','排序')->col(8),
|
|
|
+ Form::radio('is_show','产品状态',0)->options([['label'=>'上架','value'=>1],['label'=>'下架','value'=>0]])->col(8),
|
|
|
+ Form::radio('is_hot','热卖单品',0)->options([['label'=>'是','value'=>1],['label'=>'否','value'=>0]])->col(8),
|
|
|
+ Form::radio('is_benefit','促销单品',0)->options([['label'=>'是','value'=>1],['label'=>'否','value'=>0]])->col(8),
|
|
|
+ Form::radio('is_best','精品推荐',0)->options([['label'=>'是','value'=>1],['label'=>'否','value'=>0]])->col(8),
|
|
|
+ Form::radio('is_new','首发新品',0)->options([['label'=>'是','value'=>1],['label'=>'否','value'=>0]])->col(8),
|
|
|
+ Form::radio('is_postage','是否包邮',0)->options([['label'=>'是','value'=>1],['label'=>'否','value'=>0]])->col(8)
|
|
|
+];
|
|
|
+$form = Form::create(Url::build('save'));
|
|
|
+$form->setMethod('post')->setTitle('添加产品')->components($field);
|
|
|
+$this->assign(compact('form'));
|
|
|
+return $this->fetch('public/form-builder');
|
|
|
+
|
|
|
+```
|
|
|
+#### 效果
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
**当form提交成功后会调用`window.formCreate.formSuccess(res,$f,formData)`作为回调方法**
|
|
|
|
|
|
|
|
|
@@ -127,6 +197,7 @@ echo $html;
|
|
|
* @method $this justify(String $justify) flex 布局下的水平排列方式,可选值为start、end、center、space-around、space-between
|
|
|
* @method $this className(String $className) 自定义的class名称
|
|
|
```
|
|
|
+参考: [view col栅格布局](http://v2.iviewui.com/components/grid#API)
|
|
|
|
|
|
## Col栅格规则
|
|
|
* **Form::col**
|
|
|
@@ -143,6 +214,7 @@ echo $html;
|
|
|
* @method $this md(Number|Col $span) ≥992px 响应式栅格,可为栅格数或一个包含其他属性的对象
|
|
|
* @method $this lg(Number|Col $span) ≥1200px 响应式栅格,可为栅格数或一个包含其他属性的对象
|
|
|
```
|
|
|
+参考: [view col栅格布局](http://v2.iviewui.com/components/grid#API)
|
|
|
|
|
|
|
|
|
## select,checkbox,radio组件配置options专用方法
|
|
|
@@ -416,4 +488,12 @@ echo $html;
|
|
|
* @method $this checked(Boolean $bool) 是否勾选(如果勾选,子节点也会全部勾选)
|
|
|
* @method $this children(array $children) 批量设置子集
|
|
|
* @method $this child(TreeData $child) 设置子集
|
|
|
-```
|
|
|
+```
|
|
|
+
|
|
|
+##所有组件生成效果
|
|
|
+
|
|
|
+
|
|
|
+## 参考
|
|
|
+
|
|
|
+ui框架: [iview2.x](http://v2.iviewui.com/docs/guide/install)
|
|
|
+js表单生成器生成: [form-create](https://github.com/xaboy/form-create)
|