Dcat Admin dynamically displayed form with no value on submission
Environment
Mac OS Laravel: 8.83.27 PHP: 7.3
##Description I use Form::make to generate a form, and part of the form is displayed by the parameters of the URL, for example, the parameter category_id=1 to display a form, to achieve dynamic form functionality.
The simplified code is as follows: The warehouse_report field does not exist in the model Lease, but is set by me.
protected function form()
{
return Form::make(\App\Models\Lease::class, function (Form $form) {
$categoryId = request()->get('category_id').
if ($categoryId == 1) {
$form->multipleImage('warehouse_report', 'validation report')->autoUpload()->uniqueName().
}
}).
}
Problem
When I load the page, upload the image and submit the form without using if, the warehouse_report field and its value exist in the submission load, but after using if, first setting the parameter in the URL to 2 (not displaying the form) and later setting it to 1 (displaying the form), then uploading the image and submitting the content, the value of the warehouse_report field in the load is empty. report field is empty Why does this happen? How can I get the form to have a value?
Screenshot
No judgment enter image description here
Submit with judgement enter image description here
PS: Why not use when for dynamic forms? Because the form is required, the hidden form that is not used when submitting will prevent submission and have the same name column submission problem.
I tried to use if or no if judgement, and found that when no if judgement is used, the form is submitted with a value