Send data from edit page to create page on a different resource.

Im using Laravel v10 and Filament PHP v3 I have the following models: Client LegacyClient I want to allow users to re-use the legacy client data to create a new client record. For this I want to create a form action that 'sends' the data from the form in EditLegacyClient.php page to the form in CreateClient.php page. On my EditLegacyClient.php page I have:
protected function getHeaderActions(): array
{
return [
// Recycle Legacy Client Data Action btn.
Action::make('recycle')
->label('New Client (Recyle)')
->action(function (array $data): void {
//Data from the form in EditLegacyClient.php
$name = $data['name'];
$telephone = $data['telephone'];

//Variables to be sent to the form in CreateClient.php page
$data['name'] = $name;
$data['telephone'] = $telephone;
})
->color('warning')
->icon('heroicon-s-arrow-path')
->requiresConfirmation()
->modalHeading('Create new client using Legacy Client data?')
->modalDescription('Confirm your intention to reuse this legacy client data to create a new client record.')
->modalSubmitActionLabel('New Client (Recyle)')
->visible(
fn () => in_array(Auth()->user()->role, ['SUPERADMIN', 'ADMIN', 'MANAGER', 'ASSOCIATE'])
),
];
}
protected function getHeaderActions(): array
{
return [
// Recycle Legacy Client Data Action btn.
Action::make('recycle')
->label('New Client (Recyle)')
->action(function (array $data): void {
//Data from the form in EditLegacyClient.php
$name = $data['name'];
$telephone = $data['telephone'];

//Variables to be sent to the form in CreateClient.php page
$data['name'] = $name;
$data['telephone'] = $telephone;
})
->color('warning')
->icon('heroicon-s-arrow-path')
->requiresConfirmation()
->modalHeading('Create new client using Legacy Client data?')
->modalDescription('Confirm your intention to reuse this legacy client data to create a new client record.')
->modalSubmitActionLabel('New Client (Recyle)')
->visible(
fn () => in_array(Auth()->user()->role, ['SUPERADMIN', 'ADMIN', 'MANAGER', 'ASSOCIATE'])
),
];
}
Can someone please help me on how can I send the data across from the form in EditLegacyClient.php page to the form in CreateClient.php page? Thanks...
0 Replies
No replies yetBe the first to reply to this messageJoin