z-song / laravel-admin

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

Form select load, how to pass additional criteria #5641

Open technilogics opened 2 years ago

technilogics commented 2 years ago

Description:

I have an optional user_id select/dropdown in form

$form->select('user_id', __('User'))->options(User::where([['status','=',1]])->pluck('name', 'id'));

and 2 more dropdown to load brands and models

$form->select('brand_id', __('Brand'))->options(Brand::all()->pluck('title_en', 'id'))->load('model_id', '/admin/load-models')->rules('required');
$form->select('model_id', __('Model'))->options(BrandModel::all()->pluck('title_en', 'id'))->rules('required');

How i can load Models that belongs to user, if any selected.

A user can have some brands and models already in table, if a user selected, list should be only that belongs to user, otherwise load all models

In other words for brands ->load('model_id', '/admin/load-models') only brand id passed and available in controller, how i can pass additional criteria.

Steps To Reproduce:

Yanghsuanming commented 2 years ago

check this.

image