0
I’m a beginner with Laravel and I’m using Laravel 5.3 with the Admin Panel called Laravel-admin (https://github.com/z-song/laravel-admin)
I need to get the answer of a radio button with Ajax before submitting the form.
The situation is so:
Do you use Medicines? () Yes ()No
If he dials Yes, then I have to ask what or what medications he takes.
select works and stores in a good way, but I can’t get the form that is generic for everyone to implement a div or something similar that depending on the answer I show or not the next question.
My current code is:
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
return Admin::form(Aluno::class, function (Form $form) {
$form->display('id', 'ID');
$form->text('Matricula','Matrícula')->rules('required|min:5');
$form->text('Nome','Nome do Aluno')->rules('required|min:4|max:50');
$form->radio('ReacaoAlergica','Possui reação alérgica a algum medicamento?')->options([1=>'Sim',0=>'Não'])->ajax('/Admin/Extensions/Tools/remedios');
// Se a resposta for Não então a próxima linha não pode ser mostrada
$form->multipleSelect('medicamentos')->options(Medicamento::all()->pluck('Nome', 'id'));
$form->divide();
$form->number('idRespFinanceiro','Cod. do Responsável Financeiro');
$form->display('created_at', 'Criado Em');
$form->display('updated_at', 'Atualizado Em');
});
}
Does anyone have any idea how to help? Thanks to everyone.
Junior, thank you for answering, but this panel doesn’t have a default View area that is generated for each controller, but a Path that is in vendor encore views form.blade.php, so if I change it I will be changing it for all Forms. Do you know any way to pass this via Controller? Call a request to include this in the View?
– Ricardo Facincani
You can pass a variable from your controller to view, and in the view check if this variable exists, if it exists you add the code above, it will work...
– JuniorNunes
Okay, I’ll test and put the result. Thank you for the strength
– Ricardo Facincani