© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
2 replies
Hemanath

How to use action and form in beforecreate() the record


    protected function beforeCreate(Form $form, $record): void
    {
        $user_id = Franchisee::find(Session::get('current_franchisee'));
        $student = $this->record->doj;
        $this->record->update([
            'doj' => Carbon::now(),
        ])
        ->action(function ($record, array $data): void {
            $record->save();
            Notification::make()
                ->title('Employee declined successfully!')
                ->success()
                ->send();
        })
        ->requiresConfirmation()
        ->modalHeading('Employee Decline')
        ->modalSubheading('Please enter the reason to decline !')
        ->form([
            Textinput::make('program_id')
                ->rows(3)
                ->cols(1)
                ->required()
                ->label(''),
        ]);
       
        
    }

    protected function beforeCreate(Form $form, $record): void
    {
        $user_id = Franchisee::find(Session::get('current_franchisee'));
        $student = $this->record->doj;
        $this->record->update([
            'doj' => Carbon::now(),
        ])
        ->action(function ($record, array $data): void {
            $record->save();
            Notification::make()
                ->title('Employee declined successfully!')
                ->success()
                ->send();
        })
        ->requiresConfirmation()
        ->modalHeading('Employee Decline')
        ->modalSubheading('Please enter the reason to decline !')
        ->form([
            Textinput::make('program_id')
                ->rows(3)
                ->cols(1)
                ->required()
                ->label(''),
        ]);
       
        
    }
its is correct way to approach this function Can you advise me how to do ....
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Use $record in table action form
FilamentFFilament / ❓┊help
3y ago
Get form values in beforeCreate() hook
FilamentFFilament / ❓┊help
2y ago
Form action - save and load next record -
FilamentFFilament / ❓┊help
2y ago
Using $record into beforeCreate() method
FilamentFFilament / ❓┊help
3y ago