© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
8 replies
Pablo Torres

Customizing data before saving

On my BD I have:
$table->boolean('is_ready')->default(false);
$table->dateTime('marked_ready_at')->nullable();
$table->boolean('is_ready')->default(false);
$table->dateTime('marked_ready_at')->nullable();


On my form, I have:
Forms\Components\Toggle::make('is_ready'),
Forms\Components\Toggle::make('is_ready'),


In my model, I have:
protected $casts = [
        'marked_ready_at' => 'datetime',
        'created_at' => 'datetime',
        'updated_at' => 'datetime',
    ];
protected $casts = [
        'marked_ready_at' => 'datetime',
        'created_at' => 'datetime',
        'updated_at' => 'datetime',
    ];


I want when the toggle is used the 'marked_ready_at' to automatically grab the current date/time.

I have tried the following:
On my Pages/Edit

protected function mutateFormDataBeforeSave(array $data): array
{
    if ($this->record->is_ready) {
        $data['marked_ready_at'] = now();
    }

    return $data;
}
protected function mutateFormDataBeforeSave(array $data): array
{
    if ($this->record->is_ready) {
        $data['marked_ready_at'] = now();
    }

    return $data;
}


What I/m doing wrong?
Is there a better approach?
Thanks.
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

Customizing data before saving in Relation Manager
FilamentFFilament / ❓┊help
3y ago
relation manager customizing data before saving not working!
FilamentFFilament / ❓┊help
3y ago
Customizing data before filling the form
FilamentFFilament / ❓┊help
2y ago
Mutate ManageRelatedRecords data before saving
FilamentFFilament / ❓┊help
2y ago