z-song / laravel-admin

Build a full-featured administrative interface in ten minutes
https://laravel-admin.org
MIT License
11.12k stars 2.81k forks source link

Cascading Select not working #5804

Open faruktunc opened 1 year ago

faruktunc commented 1 year ago

Description:

I am trying to do Cascading Select as given in the documentation. Data can be pulled correctly. However, this data does not come to select.

Steps To Reproduce:

MalzemeControler.php

$form->select('depo_id', 'Depo Seçiniz')->options(Depo::all()->pluck('DepoAdi', 'id'))
            ->load('raf_id', '/api/raf');
$form->select('raf');

---api result and route---- /api/raf?q=1 result:

     [
    {
    "id": 1,
    "text": "A Rafı"
  },
  {
    "id": 2,
    "text": "B Rafı"
  },
  {
    "id": 3,
    "text": "C Rafı "
  }
]

in api.php -> Route::get('/raf',[RafApiController::class,'raf']);

And Here is the api controller function

    public function raf(Request $request){
        $depoId =$request->q;
        return (Raf::where('depo_id', $depoId)->get(['id', DB::raw('rafAdi as text')]));
    }

When I do it manually (via link) I can get results. When I select any option on the form, nothing changes. No data is coming

Yanghsuanming commented 1 year ago

image