F
Filament4mo ago
Zod

How do I mutateFormDataBeforeFill for a relation edit?

I have relationship manager but the function is not working there..
9 Replies
Tieme
Tieme4mo ago
What do you want to mutate? Is this on a action form or what form is it?
Zod
Zod4mo 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
Tieme4mo 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
Zod4mo ago
Yeah, thats not working there Same for afterSave(), would like to use that aswel
LeandroFerreira
LeandroFerreira4mo 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
Zod4mo ago
I need to access the record Any ideas how I can do that? Even further I need to access the db
Zod
Zod4mo ago
This is awesome, thanks! Any ideas about the afterSave?
LeandroFerreira
LeandroFerreira4mo ago
->after() in the EditAction?