Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

多级联动无法获取信息 #2151

Open
sudo-vector opened this issue Dec 26, 2024 · 0 comments
Open

多级联动无法获取信息 #2151

sudo-vector opened this issue Dec 26, 2024 · 0 comments

Comments

@sudo-vector
Copy link

  • Laravel Version: laravel 9.58.2
  • PHP Version: 8.1.10
  • Dcat Admin Version: 2.2.2

Description:

我设计了现员工管理的多级联动功能
protected function form()
{
return Form::make(new Team(), function (Form $form) {
$form->display('id');
$form->select('branch_id', '分公司')

        ->options(Branch::all()->pluck('name', 'id'))
        
        ->load('department_id', 'api/employee?type=department&q=:branch_id')
        ->required();
    
    $form->select('department_id', '部门');
        ->options(function ($id) {
            \Log::info('Department options callback with branch_id:', ['branch_id' => $id]);
            
            // 这里应该返回部门列表,假设Branch模型关联了Department模型
            return Department::where('branch_id', $id)->pluck('name', 'id');
        });
       
        $form->text('name', '组名')->required();
    
        $form->text('manager_id');
       
      
    
        $form->display('created_at');
        $form->display('updated_at');
    });
}

发现api调用成功[2024-12-26 03:20:17] local.INFO: Cascade Request {"type":"department","parentId":"1"}
[2024-12-26 03:20:17] local.INFO: Cascade Response {"options":{"Illuminate\Support\Collection":{"1":"企业部","2":"人才组","3":"企业部"}}} ,但是department $id 为null,无法select 部门

Steps To Reproduce:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant