fastadmin权限树。树形下拉框

fastadmin 笔记

权限树

在这里插入图片描述
在构造方法中编写相应的代码
值得一提的是,你的表必须有 id 字段以及 pid 字段。



 // 必须将结果集转换为数组
        $ruleList = \think\Db::name("state_list")->field('createtime,updatetime', true)->order('id ASC')->select();
        foreach ($ruleList as $k => &$v) {
   
            $v['title'] = __($v['title']);
        }
        unset($v);
        Tree::instance()->init($ruleList);
        $this->rulelist = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0), 'title');
        $ruledata = [0 => __('None')];
        foreach ($this->rulelist as $k => &$v) {
   
//            if (!$v['ismenu']) {
   
//                continue;
//            }
            $ruledata[$v['id']] = $v['title'];
            unset($v['spacer']);
        }
        unset($v);
        $this->view->assign('ruledata', $ruledata);

这里我们 写的是 ruledata

在前端页面 调用 ruledata

添加页面


    <div class="form-group">
        <label  class="control-label col-xs-12 col-sm-2">{
   :__('State_list_id')}:</label>
        <div class="col-xs-12 col-sm-8">
            {
   :build_select('row[state_list_id]', $ruledata, null, ['class'=>'form-control', 'required'=>''])}
        </div>
    </div>

编辑页面
和添加页面不同的地方在于,编辑会有一个默认值,添加中为“ null ” 的地方 填写上你的字段。


    <div class="form-group">
        <label  class="control-label col-xs-12 col-sm-2">{
   :__('State_list_id')}:</label>
        <div class="col-xs-12 col-sm-8">
            {
   :build_select('row[state_list_id]', $ruledata, $row['state_list_id'], ['class'=>'form-control', 'required'=>''])}
        </div>
    </div>

相关推荐

  1. vue2 el-tree树形

    2023-12-08 07:44:02       26 阅读
  2. selenium处理、警告

    2023-12-08 07:44:02       31 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-08 07:44:02       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-08 07:44:02       106 阅读
  3. 在Django里面运行非项目文件

    2023-12-08 07:44:02       87 阅读
  4. Python语言-面向对象

    2023-12-08 07:44:02       96 阅读

热门阅读

  1. Ubuntu 20.04 安装Orthanc

    2023-12-08 07:44:02       54 阅读
  2. extern”C”的作用及注意事项

    2023-12-08 07:44:02       61 阅读
  3. 微信小程序uni-app:常用Form表单组件使用示例

    2023-12-08 07:44:02       61 阅读
  4. Boost:asio多io_service,多线程run

    2023-12-08 07:44:02       49 阅读
  5. 使用单例模式+观察者模式实现参数配置实时更新

    2023-12-08 07:44:02       45 阅读
  6. 芯知识 | 什么是单片机语音芯片?

    2023-12-08 07:44:02       69 阅读
  7. GO设计模式——11、装饰器模式(结构型)

    2023-12-08 07:44:02       55 阅读
  8. TrustZone概述

    2023-12-08 07:44:02       57 阅读
  9. 生信数据分析高效Python代码

    2023-12-08 07:44:02       49 阅读