Skip to content

动态显示字段

单选表单联动

支持的类型:radio,switch,radioCard,radioButton,select

显示不同组件

php
$form->radio("level","类型")->options(["文本","单选","多选"])->when(0,function (Form $form){
                $form->text("money", "金额")->autoWidth();
            })->when(1,function (Form $form){
                $form->selectTable("user_id", "用户")
                    ->controller("Cusertable")->title("选择用户")->asynModel("id", "nickname", "user");
            })->when(2,function (Form $form){
                $form->multipleSelectTable("user_id_list", "多用户")
                    ->controller("Cusertable")->title("选择用户")->asynModel("id", "nickname", "user");
            });

显示共同组件

php
$form->radio("level","类型")->options(["文本与开关","选择器与开关","文本"])->when("in",[0,1],function (Form $form){
            $form->switch("level2", "开关");
        })->when(1,function (Form $form){
            $form->select("level3","等级")->options(["等级1","等级2","等级3"]);
        })->when("in",[0,2],function (Form $form){
            $form->textarea("textarea", "文本块");
        });

多选组件

支持的类型:checkbox,multipleSelect,checkboxButton,checkboxCard

php
 $form->checkbox("level_select","类型")->options(["文本与开关","选择器与开关","文本"])->when("oneIn",[0,1],function (Form $form){
            $form->switch("level4", "开关");
        })->when("oneIn",[1],function (Form $form){
            $form->select("level5","等级")->options(["等级1","等级2","等级3"]);
        })->when("oneIn",[0,2],function (Form $form){
            $form->text("text", "文本");
        });