ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
### 方法 动态控件实例: ```php $dynamicControl= $formControl->dynamicControl(); ``` 设置皮肤:`默认 'lay-skin' => 'nob', 'lay-size' => 'sm'` > 支持以下选项 * - lay-skin=grid 全边框 * - lay-skin=line 行边框表格 * - lay-skin=row 列边框表格 * - lay-skin=nob 无边框 * * - lay-size=sm 小尺寸 * - lay-size=lg 大尺寸 * - lay-even="" 偶数行背景色 ```php $dynamicControl->skinAttribute([ 'lay-skin' => 'line' ]); ``` 设置允许拖拽排序: ```php $dynamicControl->allowDragSorting() ``` 设置允许删除默认行: ```php $dynamicControl->allowDefaultDrop() ``` 全局设置单元格最小宽度: `默认: 80` ```php $dynamicControl->cellMinWidth(100) ``` 设置控件标签: ```php $dynamicControl->label('文本'); ``` 设置默认数据: ```php $dynamicControl->data([ [ 'field1' => 1, 'field2' => 2, // ... ], [ 'field1' => 3, 'field2' => 4, // ... ], ]); ``` 设置控件项: ```php $dynamicControl->items([ 'm' => $this->dynamicControl->file() ->label('测试一下啊') ->scenarioImage() ->scenarioVideo() ->scenarioOther() ->max(1) ->defaultValue(['https://tfs.alipayobjects.com/images/partner/TB1TrI3cTVyDuNk6XeaXXXCWXXa']) ->style(['width' => '50px', 'height' => '50px']), 'a' => $this->dynamicControl->checkbox()->label('多选')->options(['1' => '男', '2' => '女'])->required()->minWidth(150), 'd' => $this->dynamicControl->month()->label('月')->required(), 'e' => $this->dynamicControl->number()->label('数字')->required(), 'f' => $this->dynamicControl->password()->label('密码')->required(), ]) ``` 设置注释文本: ```php $dynamicControl->comment('这里是一个注释文本'); ``` 设置栅栏布局 (默认:12`): ```php $dynamicControl->layout(6); ``` 设置ui类: ```php $dynamicControl->uiClass(['f13']); ``` 设置style样式: ```php $dynamicControl->style(); ``` 设置html属性: ```php $dynamicControl->attribute(); ``` ### 链式调用 ~~~ $formBuilder->setFormControl([ 'a' => $this->formControl->text()->label('普通文本'), ]) ~~~ ### 代码示例 ~~~ public function actionAdd() { if ($this->isPost) { // return $this->as403('登录已失效!'); return $this->asOk('删除成功!'); // return $this->asFail('删除失败, 参数错误!'); } else { $get = $this->filteredGet; $viewBuilder = $this->viewBuilder; $viewBuilder->setPartial(); $form = $viewBuilder->form; $form->registerPointcut(H5::alert('我是表单切点', 'info', ['class' => ['mb-0']])) ->setFormControl([ 'j' => $this->formControl->textarea()->label('文本域')->required()->defaultValue('卧槽我\r\n卧槽"\'' . PHP_EOL), 'k' => $this->formControl->checkbox()->defaultValue(['a'])->options(['a' => '我', 'b' => '是', 'c' => '神',])->required()->label('标签')->tag(), 'l' => $this->formControl->checkbox()->defaultValue(['e', 'f'])->options(['d' => '我', 'e' => '是', 'f' => '神',])->required()->label('多选'), 'm' => $this->formControl->sw()->label('开关')->required()->checked(), 'n' => $this->formControl->hidden()->defaultValue('冲冲冲'), 'o' => $this->formControl->password()->label('密码')->required()->defaultValue('123456'), 'p' => $this->formControl->radio()->options(['g' => '我', 'h' => '是', 'i' => '神',])->defaultValue('h')->required()->label('单选'), 'q' => $this->formControl->range()->required()->label('范围')->defaultValue(1), ]) ->setCloseBtn() ->setSubmitBtn() ->setSubmittedCalls([ 'parent' => isset($get['_bid']) ? $get['_bid'] : null, ]) ->setAutoClose(true); return $viewBuilder->render(); } } ~~~