Fastadmin类别联动选择的问题

不能选择顶级类别。在/admin/Controller/Ajax.php文件里面。

/**
     * 读取分类数据,联动列表
     */
    public function category()
    {
        $type = $this->request->get('type');
        $pid = $this->request->get('pid');
        $where = ['status' => 'normal'];
        $categorylist = null;
        if ($pid !== ''){
            if ($type){
                $where['type'] = $type;
            }
   if($pid){
             $where['pid'] = $pid;   //把if条件判断去掉,这样pid传0的时候,就可以选择顶级类别了。
   }
            $categorylist = Db::name('category')->where($where)->field('id as value,name')->order('weigh desc,id desc')->select();
        }
        $this->success('', null, $categorylist);
    }

你可能感兴趣的:(fastadmin)