ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
表单触发器控件 --------- + 支持触发器的控件有: + date + datetime + month + number + password + radio + range + select(single) + xselect(radio = true) + xselectCascader(radio = true) + xselectRemote(radio = true) + xselectTree(radio = true) + selectLink + switch + text + textarea + time + year + 其他, 控件值为PHP标量,并且支持Angular Scope双向绑定 + 触发器特点 - 触发条件支持链式逻辑 - 触发条件操作符支持`==` `===` `>=` `<=` `>` `<` `!=` `!==` - 触发条件的值只支持PHP标量 + 示例: ```php /** * @return string * @throws \Throwable */ public function actionIndex() { if ($this->isPost) { return $this->asOk('success'); } else { $form = FormBuilder::instance([ 'id' => 'formDemo', ]); $form->setTitle('表单构建器') ->setRootLayout([ 'class' => ['col-md-12'] ]) ->setPartial(false) ->setRequiredStyle() ->registerPointcut(H5::alert('我是一个信息提示!')) ->setFormControl([ 'a' => $this->formControl->text()->label('用户名')->placeholder('请填写用户名'), 'b' => $this->formControl->password()->label('密码')->placeholder('请填写密码')->comment('注:密码必须包含特殊字符,且大于6位小于22位'), 'c' => $this->formControl->tag()->label('#话题')->defaultValue(['学校', '家庭', '人生', '信仰'])->required(), 'i' => $this->formControl->select()->label('触发器')->options(['a' => '触发A', 'b' => '触发B']), 'n' => $this->formControl->sw()->label('开关')->checked(), 'trigger1' => $this->formControl->trigger()->when('default', 'i', '!=', 'b')->triggerItems([ 'j' => $this->formControl->text()->label('触发器1-1'), 'k' => $this->formControl->text()->label('触发器1-2'), 'trigger3' => $this->formControl->trigger()->when('default', 'n', '==', '0')->triggerItems([ 'o' => $this->formControl->text()->label('内部触发器1-1'), 'p' => $this->formControl->text()->label('内部触发器1-2'), ])->display(), ])->display(), 'trigger2' => $this->formControl->trigger()->when('default', 'i', '==', 'b')->triggerItems([ 'l' => $this->formControl->text()->label('触发器2-1'), 'm' => $this->formControl->text()->label('触发器2-2'), ])->display(), /*'e' => $this->formControl->select()->label('分组')->multiple()->disabled(['A', 'E'])->options([ '会员列表' => [ 'A' => '数字1', 'B' => '数字2', 'C' => '数字3', ], '日志列表' => [ 'D' => '日志1', 'E' => '日志2', 'F' => '日志3', ], ]), 'f' => $this->formControl->selectLink()->label('省')->disabled(['A', 'E'])->initOptions([ '中国' => [ 'A' => '河南省', 'B' => '广东省', 'C' => '北京市', ], '美国' => [ 'D' => '华盛顿', 'E' => '剑桥', 'F' => '麻省理工', ], ])->targetLink('g')->route('form/link')->start(), 'g' => $this->formControl->selectLink()->label('市')->targetLink('h')->route('form/link')->through(), 'h' => $this->formControl->selectLink()->label('县(区)')->end(),*/ ]) ->setSubmitConfirm() ->setExtraBtn([ H5::tag('button', '额外的按钮', ['class' => ['layui-btn layui-btn-sm layui-btn-gray ym2-form-extra-ui'], 'type' => 'button']), ]) ->setSubmitBtn('确定') ->setResetBtn() ->setExtraJs([ function() { return "console.log('额外的JS')"; }, ]) ->registerPointcut(H5::alert('我是一个底部信息提示!', 'info'), FormBuilder::POS_END); return $form->render(); } } ```