© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
9 replies
Gediminas

Custom form action help

Hi,

Is there a way modify form data when submitting from a custom form action?

I've added this into my createPost.php
     protected function getFormActions(): array
     {
         return [
             $this->getCreateFormAction(),
             $this->getCreateAndSetActiveFormAction(),
             $this->getCancelFormAction(),
         ];
     }
     protected function getFormActions(): array
     {
         return [
             $this->getCreateFormAction(),
             $this->getCreateAndSetActiveFormAction(),
             $this->getCancelFormAction(),
         ];
     }


     protected function getCreateAndSetActiveFormAction(): Action
     {
         return Action::make('createandsetactive')
         ->label('Create and set active')
         ->submit('createandsetactive');
     }
     protected function getCreateAndSetActiveFormAction(): Action
     {
         return Action::make('createandsetactive')
         ->label('Create and set active')
         ->submit('createandsetactive');
     }


This button works correctly in creating a Post record, but I'd like to be modify the 'active' parameter that's in the form data and set it to TRUE before creating the record. Is such a thing possible?
Solution
You could use ->action
Action::make('createandsetactive')
    ->label('Create and set active')
    ->action(function(){
        $this->data['status'] = 'active';
        $this->create();
    })
Action::make('createandsetactive')
    ->label('Create and set active')
    ->action(function(){
        $this->data['status'] = 'active';
        $this->create();
    })
Jump to solution
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

Adding custom form action button
FilamentFFilament / ❓┊help
3y ago
Please Help - Form Action
FilamentFFilament / ❓┊help
16mo ago
Dynamic form creation for custom action
FilamentFFilament / ❓┊help
3y ago
Form action
FilamentFFilament / ❓┊help
16mo ago