Stumped on file handling files with Forms + Spatie Media on Custom Page

I'm having issues handling a file upload on a custom page. I know I'm probably doing something stupid, but wondering if anyone will give me a sanity check.
<?php
class EditAccount extends Page implements HasForms
{
// ...
public function form(Form $form): Form
{
return $form
->schema([
TextInput::make('name')
->label('Company Name')
->required(),

SpatieMediaLibraryFileUpload::make('logo'),
])
->statePath('data');
}

public function save(): void
{
$data = $this->form->getState();
dd($data); // no `logo` in the data
$account = request()->user()->account;
$account->update($data);

}
}
<?php
class EditAccount extends Page implements HasForms
{
// ...
public function form(Form $form): Form
{
return $form
->schema([
TextInput::make('name')
->label('Company Name')
->required(),

SpatieMediaLibraryFileUpload::make('logo'),
])
->statePath('data');
}

public function save(): void
{
$data = $this->form->getState();
dd($data); // no `logo` in the data
$account = request()->user()->account;
$account->update($data);

}
}
This is my custom page for a single account edit. And below is the blade view for it:
<x-filament-panels::page>
<form wire:submit="save">
{{ $this->form }}
<button class="btn btn-primary" type="submit">Save</button>
</form>
</x-filament-panels::page>
<x-filament-panels::page>
<form wire:submit="save">
{{ $this->form }}
<button class="btn btn-primary" type="submit">Save</button>
</form>
</x-filament-panels::page>
On save, the $data = $this->form->getState(); contains the name input data, but no file uploads. Is it because of the data state path? I know I'm overlooking something simple but stuck at the moment
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server