F
Filament10mo ago
Zod

How do I mutateFormDataBeforeFill for a relation edit?

I have relationship manager but the function is not working there..
9 Replies
Tieme
Tieme10mo ago
What do you want to mutate? Is this on a action form or what form is it?
Zod
ZodOP10mo ago
I want to mutate the form of the edit of loaded entities via the RelationshipManager I have a list of relations of the loaded parent and can edit them via the relationshipmanager. But I want to mutate that edit form of each loaded child
Tieme
Tieme10mo ago
Have you already tried to add function to the relationmanager class?
protected function mutateFormDataBeforeFill(array $data): array
{
$data['user_id'] = auth()->id();

return $data;
}
protected function mutateFormDataBeforeFill(array $data): array
{
$data['user_id'] = auth()->id();

return $data;
}
Zod
ZodOP10mo ago
Yeah, thats not working there Same for afterSave(), would like to use that aswel
LeandroFerreira
LeandroFerreira10mo ago
if you have one or two fields, you can use formatStateUsing in the RM form
Forms\Components\TextInput::make('your_field')
->formatStateUsing(fn (string $state): string => ucfirst($state))
Forms\Components\TextInput::make('your_field')
->formatStateUsing(fn (string $state): string => ucfirst($state))
Zod
ZodOP10mo ago
I need to access the record Any ideas how I can do that? Even further I need to access the db
Zod
ZodOP10mo ago
This is awesome, thanks! Any ideas about the afterSave?
LeandroFerreira
LeandroFerreira10mo ago
->after() in the EditAction?
Want results from more Discord servers?
Add your server