`mutateFormDataUsing()` not working on CreateAction?

In an Example app with Filament 3.0.7 I've setup a 'Tester' model with just 1 attribute - $name:
class Tester extends Model {

protected $fillable = [
'name',
];
}
class Tester extends Model {

protected $fillable = [
'name',
];
}
And generated a TestersResource for it. Now on the ListTesters::getHeaderActions() I'm trying to override the name on save:
Actions\CreateAction::make()->mutateFormDataUsing( function ( array $data ) {
$data['name'] = 'Overridden name';

return $data;
} ),
Actions\CreateAction::make()->mutateFormDataUsing( function ( array $data ) {
$data['name'] = 'Overridden name';

return $data;
} ),
The value is then not set in the model when saving. Am I doing something wrong? However setting the same mutateFormUsing on the EditAction does indeed work and set the model's $name attribute value to Overridden name.
2 Replies
Yuut4
Yuut416mo ago
use Filament\Pages\Actions\CreateAction;
use Illuminate\Database\Eloquent\Model;

CreateAction::make()
->using(function (array $data): Model {
return static::getModel()::create($data);
})
use Filament\Pages\Actions\CreateAction;
use Illuminate\Database\Eloquent\Model;

CreateAction::make()
->using(function (array $data): Model {
return static::getModel()::create($data);
})
try something like this that will modify the process of creating the record
Kanalaetxebarria
Kanalaetxebarria16mo ago
Having the same issue here. Did you find a solution?
Want results from more Discord servers?
Add your server