ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
### 方法 文件控件实例: ```php $file= $formControl->file(); ``` 设置允许添加文件的最大数量:`默认1` ```php $file->max(1); ``` 设置控件标签:`默认 空` ```php $file->label('文件'); ``` 设置默认值: ```php $file->defaultValue('/uploads/image/57c5dfs235dsfsettsfcc.png'); ``` 设置为必填: ```php $file->required(true); ``` 设置注释文本: ```php $file->comment('这里是一个注释文本'); ``` 设置栅栏布局 (默认:12`): ```php $file->layout(6); ``` 设置ui类: ```php $file->uiClass(['f13']); ``` 设置style样式: ```php $file->style(); ``` 设置类型场景: ```php $file->scenarioImage(); // 图片 $file->scenarioVideo(); // 视频 $file->scenarioAudio(); // 音频 $file->scenarioOther(); // 其他 ``` ### 链式调用 ~~~ $this->formControl->file() ->label('测试一下') ->max(5) ->scenarioImage() ->scenarioVideo() ->scenarioAudio() ->scenarioOther() ->defaultValue('https://tfs.alipayobjects.com/images/partner/TB1TrI3cTVyDuNk6XeaXXXCWXXa') ~~~ ### 代码示例 ~~~ /** * @return string * @throws \yii\base\InvalidConfigException */ public function actionTree() { if ($this->isPost) { return $this->asOk('success'); } else { $formBuilder = FormBuilder::instance(); $formBuilder->setTitle('xm-select') ->setFormControl([ 'a' => $this->formControl->xselect()->label('xm-select')->defaultValue([1])->data($this->getData())->tips('请选择一哈!')->filterable()->radio()->clickClose(), 'd' => $this->formControl->xselectTree() ->label('xm-select-tree') ->defaultValue(['6']) ->data($this->getTreeData()) ->tips('请选择一哈!') ->filterable() //->radio() //->strict(false) ->expandedKeys(true) ->addPluginOption('height', '500px') /*->clickClose()*/, 'e' => $this->formControl->xselectRemote() ->label('xm-select-remote') ->tips('请选择一哈!') ->filterable() ->radio() ->clickClose() ->toolbar([ 'show' => true, ]) ->addPluginOption('tree', [ 'show' => true, ]) ->url(Url::to('form/remote', '')) ->httpMethod('get'), 'f' => $this->formControl->xselectCascader() ->label('xm-select-cascader') ->defaultValue(['6']) ->data($this->getTreeData()) ->tips('请选择一哈!') ->radio() ->clickClose() ->strict(false), 'g' => $this->formControl->file() ->label('测试一下') ->max(5) ->scenarioImage() ->scenarioVideo() ->scenarioAudio() ->scenarioOther() ->defaultValue('https://tfs.alipayobjects.com/images/partner/TB1TrI3cTVyDuNk6XeaXXXCWXXa'), ]) ->setResetBtn() ->setSubmitBtn(); return $formBuilder->render(); } } ~~~