© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago
biebthesecond

Transfer data from form to Action Form

Hey Everyone,

On my website there's a file input that on change has to activate a modal action with additional fields. In that action there's also a file input field. I want to be able to transfer the inputted files in the form to the ones in the action.

I have of course tried the fillForm() method, but that function seems to run on loading the page and not on calling the action, so the data to transfer doesn't exist yet. There's probably a event to be called, but I haven't been able to figure it out yet and the documentation doesn't tell to much about this.

The file input in fillForm() expects data be like this: [ '<possible_directory>/<filename>.<format>', ].
The data you get from the form is exactly that. So that should work.

I hope someone can help with this.
    public function form(Form $form): Form
    {
        return $form
            ->schema([
                Forms\Components\FileUpload::make('files')
->multiple()->reactive()->directory(Auth::id())
->preserveFilenames()
->afterStateUpdated(function () {
      $this->mountAction('sendMessage');
  })
->label(''),
])
->statePath('data');
    }
    public function form(Form $form): Form
    {
        return $form
            ->schema([
                Forms\Components\FileUpload::make('files')
->multiple()->reactive()->directory(Auth::id())
->preserveFilenames()
->afterStateUpdated(function () {
      $this->mountAction('sendMessage');
  })
->label(''),
])
->statePath('data');
    }


public function sendMessageAction(): Action
    {
        return Action::make('sendMessage')
            ->label('Verstuur bericht')
            ->fillForm(['files' => $this->form->getState()['files']])
            ->form([
Forms\Components\TextInput::make('subject')
                    ->label('Naam document')
                    ->required(),
Forms\Components\FileUpload::make('files')
                    ->multiple()
                    ->previewable()
                    ->preserveFilenames()
                    ->directory('livewire-tmp')
                    ->label('Bestanden')
            ])
            ->action(function (array $data) {
                app(SaveSentMessage::class)($data);
            });
    }
public function sendMessageAction(): Action
    {
        return Action::make('sendMessage')
            ->label('Verstuur bericht')
            ->fillForm(['files' => $this->form->getState()['files']])
            ->form([
Forms\Components\TextInput::make('subject')
                    ->label('Naam document')
                    ->required(),
Forms\Components\FileUpload::make('files')
                    ->multiple()
                    ->previewable()
                    ->preserveFilenames()
                    ->directory('livewire-tmp')
                    ->label('Bestanden')
            ])
            ->action(function (array $data) {
                app(SaveSentMessage::class)($data);
            });
    }
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

get form data from action
FilamentFFilament / ❓┊help
3y ago
Action form, validate data from API
FilamentFFilament / ❓┊help
11mo ago
Set Repeater Data from Action Form
FilamentFFilament / ❓┊help
2y ago
How to get $data from table form action?
FilamentFFilament / ❓┊help
2y ago