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

3 messages · Page 1 of 1 (latest)

ember cobalt
#

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);

    }
}

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>

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

junior zephyr
#

I'm in the same situation as you. Did you find any solution?

hasty needle