CreateAction::make()->before() not being triggered.

Ok I am having a seriously stupid moment... for some reason this simple little before() call is not being fired at all O_O any ideas? The record gets created just fine... but no dd(). Which means I cant fire off other functions to do stuff. I am seriously having a brain fart. doco: https://filamentphp.com/docs/3.x/actions/prebuilt-actions/create#lifecycle-hooks
<?php

namespace App\Filament\Resources\AchievementCategoryResource\Pages;

use App\Filament\Resources\AchievementCategoryResource;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;
use Archilex\AdvancedTables\AdvancedTables;

class ListAchievementCategories extends ListRecords
{
use AdvancedTables;
protected static string $resource = AchievementCategoryResource::class;

protected function getHeaderActions(): array
{
return [
CreateAction::make()
->label('xxxxxxxxxxxxx')
->before(fn() => dd('Before creating a new record')),
];
}
}
<?php

namespace App\Filament\Resources\AchievementCategoryResource\Pages;

use App\Filament\Resources\AchievementCategoryResource;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;
use Archilex\AdvancedTables\AdvancedTables;

class ListAchievementCategories extends ListRecords
{
use AdvancedTables;
protected static string $resource = AchievementCategoryResource::class;

protected function getHeaderActions(): array
{
return [
CreateAction::make()
->label('xxxxxxxxxxxxx')
->before(fn() => dd('Before creating a new record')),
];
}
}
2 Replies
charlie
charlie3w ago
I don't know why it doesn't work, but you could use that instead:
protected function mutateFormDataBeforeCreate(array $data): array
{
//
}
protected function mutateFormDataBeforeCreate(array $data): array
{
//
}
You'll need to add it to CreateAchievementCategory class
403gtfo
403gtfoOP3w ago
Perfect, that works 😄 Many thanks.

Did you find this page helpful?