Allows submit with empty form with required field

why would i be able to submit this with no logo if its a required field?
public function form(Form $form): Form
{
return $form
->schema([
FileUpload::make('logo')
->label('Logo')
->acceptedFileTypes(
['image/png', 'image/jpeg', 'image/jpg', 'image/webp']
)
->helperText('Accepted file types: png, jpg, jpeg, webp')
->maxSize(25000)
->storeFile(false)
->required(),
])
->statePath('data')
->model($this->tenant);
}
public function form(Form $form): Form
{
return $form
->schema([
FileUpload::make('logo')
->label('Logo')
->acceptedFileTypes(
['image/png', 'image/jpeg', 'image/jpg', 'image/webp']
)
->helperText('Accepted file types: png, jpg, jpeg, webp')
->maxSize(25000)
->storeFile(false)
->required(),
])
->statePath('data')
->model($this->tenant);
}
. I am just doing the normal
<form wire:submit.prevent="save">
{{ $this->form }}

<x-filament::button type="submit" class="mt-4">
Submit
</x-filament::button>
</form>
<form wire:submit.prevent="save">
{{ $this->form }}

<x-filament::button type="submit" class="mt-4">
Submit
</x-filament::button>
</form>
. As far as i remember, I dont typically have to do a check within my save() method to validate that. Maybe Im not thinking straight? Its been a long day. lol
7 Replies
toeknee
toeknee2y ago
I'd debug the mutateBeforeSave personally and see if there is a value, required() might be detecting an empty error
awcodes
awcodes2y ago
Are you calling $this->form->fill() in mount? Out of curiosity, why are you using statePath()?
Mark Chaney
Mark ChaneyOP2y ago
Yes. Idk, habit? Thought that was standard. Worth a try
awcodes
awcodes2y ago
A lot of people miss it. Just throwing it out there. The only that looks off to me is the statePath(). That’s not standard.
Andrew Wallo
Andrew Wallo2y ago
You could try statePath('logo') and see if that works if you want to keep it for some reason.
Mark Chaney
Mark ChaneyOP2y ago
I just used @awcodes drop in action package and called it a day. Solved a few UX issues for me as well
toeknee
toeknee2y ago
Yeah it's sick
Want results from more Discord servers?
Add your server