F
Filamentβ€’6mo ago
ericmp

CreateRecord equivalency for EditRecord - mutateFormDataBeforeFill

In the EditRecord i use the mutateFormDataBeforeFill:
protected function mutateFormDataBeforeFill(array $data): array
{
$data['test'] = 'ok';

return $data;
}
protected function mutateFormDataBeforeFill(array $data): array
{
$data['test'] = 'ok';

return $data;
}
So how to do it in the CreateRecord? I've tried to find a similar method, but im not lucky so far πŸ€” I want to do the same, mutate $data, so it contains 'test' with a value
Solution:
So you want a field to be prefilled when you are on the CreatePage? If so you would use the ->default() for the given field. For example TextInput::make('dummy')->default('foo') Or what exactly is it that you are trying to achieve?...
Jump to solution
4 Replies
dissto
disstoβ€’6mo ago
There is a ->mutateFormDataBeforeCreate though. You can do the same there which will be fun upon creating
ericmp
ericmpβ€’6mo ago
yeah, but as the method name says, it mutates form data before create i already tried it before ur msg it doesnt work i need to mutate form data before fill
Solution
dissto
disstoβ€’6mo ago
So you want a field to be prefilled when you are on the CreatePage? If so you would use the ->default() for the given field. For example TextInput::make('dummy')->default('foo') Or what exactly is it that you are trying to achieve?
ericmp
ericmpβ€’6mo ago
oh yeah i think that is what im looking for, let me check real quick yeah, it works ookay thanks πŸ™
Want results from more Discord servers?
Add your server