It is not possible to use a variable inside the make() of a FileUpload field ?
I try to make a dynamic field for a file but I get an error when I don't put a string directly inside the make()
error : No synthesizer found for key: ""
field :
Forms\Components\FileUpload::make($eye."_pdf")
->name("{$eye}_pdf")
->label('Fichier PDF')
->directory('aic-surgery')
->hidden(fn ($get) => !self::isFieldVisible($eye, 'pdf', $get)),
and $eye = 'left' or 'right'5 Replies
With the 'make()' function your specify in which DB field the file reference for the upload is stored. That is not the file name itself. What I think you want to do is rename the files after the user uploaded them. Use the FileUpload component function 'getUploadedFileNameForStorageUsing()' for this. See https://filamentphp.com/docs/3.x/forms/fields/file-upload#generating-custom-file-names
not really, here is my entire file :
the thing is I try to make a dynamic form for this cause I need it twice,it works very well for my other fields with this in CreatePatient :
and it works very well exept for file upload
The synthesizer error is coming from livewire/livewire/src/Mechanisms/HandleComponents/HandleComponents.php line 498. I would suggest to set a breakpoint on this line where $key=='' and check the context and path variables.
I'm not familiar what the '->name("{$eye}_pdf")' part of the FileUpload definition is supposed to do. Maybe give it a try without.
I tried to add it to see if it changes something after but it does nothing, I will remove it
I'll check for the breakpoint, thank you !
I got this :
with this in the file :
if ($key === '') {
\Log::error('Synthesizer error', ['context' => $context, 'path' => $path]);
throw new \Exception('No synthesizer found for key: "'.$key.'"');
}