F
Filament3mo ago
hootch

Fill form in CreateAction

i have Offices and Members, if a member is created from an already existing office office_id should be forced (pre-filled) i created a MembersRelationManager that extends RelationManager, i have MembersTable with headerActions:
CreateAction::make()
->label('Create New Member')
->successNotificationTitle('Member created successfully')
->mutateDataUsing(function (array $data): array {
$data['office_id'] = $this->getOwnerRecord()->id;
return $data;
}),
CreateAction::make()
->label('Create New Member')
->successNotificationTitle('Member created successfully')
->mutateDataUsing(function (array $data): array {
$data['office_id'] = $this->getOwnerRecord()->id;
return $data;
}),
mutateDataUsing is setting the office_id after creating and before inserting to DB, but what i want is to fill the form with office_id initially, is there any way to pre-fill the form, or set data somewhere so it can reflect into the form? PS: EditAction in the other hand has mutateRecordDataUsing which does the job
EditAction::make()
->slideOver()
->successNotificationTitle('Member updated successfully')
->mutateRecordDataUsing(function (array $data): array {
$data['office_id'] = $this->getOwnerRecord()->id;

return $data;
}),
EditAction::make()
->slideOver()
->successNotificationTitle('Member updated successfully')
->mutateRecordDataUsing(function (array $data): array {
$data['office_id'] = $this->getOwnerRecord()->id;

return $data;
}),
Solution:
You use use the ->fillForm() method on the CreateAction
Jump to solution
2 Replies
Solution
Dennis Koch
Dennis Koch3mo ago
You use use the ->fillForm() method on the CreateAction
hootch
hootchOP3mo ago
it worked, thank you for your accurate and quick reply

Did you find this page helpful?