P
P
Pradd_by2019-05-11 12:17:35
Laravel
Pradd_by, 2019-05-11 12:17:35

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('Выбирать, только если дверь без панели.');

Maybe I’m writing something that’s not clear, or something is missing for an answer, say, I’m here for the first time)))

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
Pradd_by, 2019-05-27
@Pradd_by

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

K
Konstantin Timosheno, 2019-05-21
@kastembay

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.

B
bukpytka, 2020-05-27
@bukpytka

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 question

Ask a Question

731 491 924 answers to any question