💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
### 控制器 ```php $dctrlHelper = $this->dynamicControl ``` ### 助手 ```php $dctrlHelper = \builder\helper\Form::dynamicControl(); ``` ### 单例化 ```php $dctrlHelper = new \builder\form\util\control\dctrl\DctrlHelper(); ``` ## 示例 ~~~ /** * @return string * @throws \Throwable */ public function actionDynamicControl() { if ($this->isPost) { return $this->asOk('表单提交成功'); } else { $formBuilder = FormBuilder::instance(); $formBuilder->setTitle('表单动态控件') ->setGroup('会员中心', 'center') ->setGroupCol(4) ->setFormControl([ 'user' => $this->formControl->text()->label('用户名'), 'member1' => $this->formControl ->dynamicControl() ->label('动态控件1') ->comment('注:这是注释') ->allowDragSorting() ->allowDefaultDrop() ->layout(12) ->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(), // 'g' => $this->dynamicControl->radio()->label('单选')->options(['1' => '男', '2' => '女'])->required()->minWidth(200), // 'h' => $this->dynamicControl->range()->label('滑块')->required(), // 'i' => $this->dynamicControl->section()->label('区间')->required()->firstStyle('width:60px;')->lastStyle('width:60px;')->minWidth(200), // 'j' => $this->dynamicControl->select()->label('下拉选择')->options(['1' => '男', '2' => '女'])->required()->minWidth(150), // 'k' => $this->dynamicControl->sw()->label('开关')->required(), // 'l' => $this->dynamicControl->text()->label('文本')->required(), ])->data([ [ 'a' => ['1' => 1], 'd' => '2020-02', 'e' => '100', 'f' => '100', // 'g' => '1', // 'h' => 50, // 'i' => ['1', '110'], // 'j' => 1, // 'k' => 1, // 'l' => '文本', ], [ 'a' => ['2' => 1], 'd' => '2020-02', 'e' => '100', 'f' => '100', // 'g' => '2', // 'h' => 50, // 'i' => ['1', '110'], // //'j' => 2, // 'k' => 0, // 'l' => '文本', ], ]), 'member2' => $this->formControl ->dynamicControl() ->label('动态控件2') ->comment('注:这是注释') ->allowDragSorting() ->allowDefaultDrop() ->layout(12) ->items([ '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(), // 'g' => $this->dynamicControl->radio()->label('单选')->options(['1' => '男', '2' => '女'])->required()->minWidth(200), // 'h' => $this->dynamicControl->range()->label('滑块')->required(), // 'i' => $this->dynamicControl->section()->label('区间')->required()->firstStyle('width:60px;')->lastStyle('width:60px;')->minWidth(200), // 'j' => $this->dynamicControl->select()->label('下拉选择')->options(['1' => '男', '2' => '女'])->required()->minWidth(150), // 'k' => $this->dynamicControl->sw()->label('开关')->required(), // 'l' => $this->dynamicControl->text()->label('文本')->required(), ])->data([ [ 'a' => ['1' => 1], 'd' => '2020-02', 'e' => '100', 'f' => '100', // 'g' => '1', // 'h' => 50, // 'i' => ['1', '110'], // 'j' => 1, // 'k' => 1, // 'l' => '文本', ], [ 'a' => ['2' => 1], 'd' => '2020-02', 'e' => '100', 'f' => '100', // 'g' => '2', // 'h' => 50, // 'i' => ['1', '110'], // //'j' => 2, // 'k' => 0, // 'l' => '文本', ], ]), ]) ->setGroup('用户中心', 'user') ->setGroupCol(4) ->setFormControl([ 'user' => $this->formControl->text()->label('用户名'), 'member1' => $this->formControl ->dynamicControl() ->label('动态控件3') ->comment('注:这是注释') ->allowDragSorting() ->allowDefaultDrop() ->layout(12) ->items([ '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(), // 'g' => $this->dynamicControl->radio()->label('单选')->options(['1' => '男', '2' => '女'])->required()->minWidth(200), // 'h' => $this->dynamicControl->range()->label('滑块')->required(), // 'i' => $this->dynamicControl->section()->label('区间')->required()->firstStyle('width:60px;')->lastStyle('width:60px;')->minWidth(200), // 'j' => $this->dynamicControl->select()->label('下拉选择')->options(['1' => '男', '2' => '女'])->required()->minWidth(150), // 'k' => $this->dynamicControl->sw()->label('开关')->required(), // 'l' => $this->dynamicControl->text()->label('文本')->required(), ])->data([ [ 'a' => ['1' => 1], 'd' => '2020-02', 'e' => '100', 'f' => '100', // 'g' => '1', // 'h' => 50, // 'i' => ['1', '110'], // 'j' => 1, // 'k' => 1, // 'l' => '文本', ], [ 'a' => ['2' => 1], 'd' => '2020-02', 'e' => '100', 'f' => '100', // 'g' => '2', // 'h' => 50, // 'i' => ['1', '110'], // //'j' => 2, // 'k' => 0, // 'l' => '文本', ], ]), 'member2' => $this->formControl ->dynamicControl() ->label('动态控件4') ->comment('注:这是注释') ->allowDragSorting() ->allowDefaultDrop() ->layout(12) ->items([ '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(), // 'g' => $this->dynamicControl->radio()->label('单选')->options(['1' => '男', '2' => '女'])->required()->minWidth(200), // 'h' => $this->dynamicControl->range()->label('滑块')->required(), // 'i' => $this->dynamicControl->section()->label('区间')->required()->firstStyle('width:60px;')->lastStyle('width:60px;')->minWidth(200), // 'j' => $this->dynamicControl->select()->label('下拉选择')->options(['1' => '男', '2' => '女'])->required()->minWidth(150), // 'k' => $this->dynamicControl->sw()->label('开关')->required(), // 'l' => $this->dynamicControl->text()->label('文本')->required(), ])->data([ [ 'a' => ['1' => 1], 'd' => '2020-02', 'e' => '100', 'f' => '100', // 'g' => '1', // 'h' => 50, // 'i' => ['1', '110'], // 'j' => 1, // 'k' => 1, // 'l' => '文本', ], [ 'a' => ['2' => 1], 'd' => '2020-02', 'e' => '100', 'f' => '100', // 'g' => '2', // 'h' => 50, // 'i' => ['1', '110'], // //'j' => 2, // 'k' => 0, // 'l' => '文本', ], ]), ]) ->setResetBtn() ->setSubmitBtn(); return $formBuilder->render(); } } ~~~