Sending data from a custom page to another custom page
Hello colleagues. I'm developing a survey application with Filament and I'm encountering the following problem.
I have two panels: adminpanel and employeepanel.
From the employeepanel, users access a custom page (ListSurveyEmployee) that displays a list of the surveys they need to complete.
In each of these records, I've created an ACTION called TAKE SURVEY. This is the code for my ACTION.
Action::make('makeSurvey')
->label('Realizar Encuesta')
->icon('heroicon-o-pencil')
->color('success')
->visible(function ($record) {
return $record->status === 'pendiente';
})
->url(fn ($record) => route('filament.employee.pages.create-survey-employee', ['survey' => $record->id]))
When the user clicks on this option, they are redirected to another custom page (CreateSurveyEmployee), where a form should be displayed with the fields to complete for the assigned survey.
The problem I'm having is that I don't know how to collect the ID of the survey the user wants to complete on the CreateSurveyEmployee custom page so I can then create the logic.
This is the custom page code that should collect the parameter.
class CreateSurveyEmployee extends Page
{
protected static bool $shouldRegisterNavigation = false;
protected static string $view = 'filament.employee.pages.create-survey';
protected static ?string $title = 'Realización de Encuesta';
public function form(Form $form): Form
{
return $form
->schema([
]); } } Can anyone help me with this? Thanks.
]); } } Can anyone help me with this? Thanks.
1 Reply
Hi colleagues, I'm still working on this issue and can't seem to capture the parameter sent via URL on the custom page.
I'll show you the changes I've made:
1. I've registered the custom page in the employee dashboard that will capture the parameter sent via URL.
public static function getPages(): array
{
return [
'newsurvey' => Pages\CreateSurveyEmployee::route('/newsurvey/{survey}'),
];
}
2. On the custom page (ListSurveyEmployee) that displays the list of surveys with the corresponding action, I add the parameter sent via URL.
Action::make('makeSurvey')
->label('Realizar Encuesta')
->icon('heroicon-o-pencil')
->color('success')
->visible(function ($record) {
return $record->status === 'pendiente';
})
->url(fn(Survey $record): string => CreateSurveyEmployee::getUrl(['survey' => $record->id])),
3. Finally, on the custom page (CreateSurveyEmployee), I need to capture the parameter sent.
How should I do this? I can't save the parameter sent.
Regards.