Answer the question
In order to leave comments, you need to log in
Help with laravel-admin. form?
In the add or edit form ($form), I want a new input field to appear when the checkbox is toggled.
Piece code:
$form->radio('prefabricated', 'В сборе / Без панели')->options([1 => 'В сборе', 0 => 'Без панели'])->required()->default(1);
$form->select('door_panel_id', 'Панели для двери')
->options(DoorPanel::all(['id', 'name'])->pluck('name', 'id'))
->rules('nullable|exists:door_panels,id')->help('Выбирать, только если дверь без панели.');
Answer the question
In order to leave comments, you need to log in
How to do this through the same ajax, I can roughly imagine, but how to do it in this admin panel according to its rules, without crutches, if possible.
The solution appeared in version 1.8.0 - Form linkage
https://laravel-admin.org/docs/en/model-form-linkage
If I understand you correctly, you need to do something through JS, that is, display a field that is initially hidden. I'm on my phone, so I can't post an example.
you can try to create your own field that will inherit the existing Radio, create a method for it, similar to the load () method of the Select field. Then register your field in the app/Admin/bootstrap.php file. For example: Encore\Admin\Form::extend('name of the method to access this field', Field class::class);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question