I use Laravel Filament in my project. When I create an input as follows:
TextInput::make("title")->filled()
This shows a notification when I try to submit with an empty title field.
But same filled() function doesn’t work with FileUpload. When I submit form without image, form proceeds without a notification. What am I missing?
FileUpload::make('image')
->columnSpan('full')
->filled()
->disk('public')
->directory('gallery')
->visibility('public')
->imageResizeMode('force')
->imageCropAspectRatio('8:5')
->imageResizeTargetWidth('800')
->imageResizeTargetHeight('500')
->image()
->imageEditor()
2
Answers
Try using
nullable
method, It gives you the same popup asfilled
But it adds the required CSS class after the label.
If you want to validate a
FileUpload
field to ensure that it contains a file, you can use the required() validation ruleor a custom validation rule named
ImageRequired
.