Pass value from Modal form to Action on list page

I have a form modal on a list page triggered from a header action (not a table row action). How do I grab that value in the 'ListRecords' components action? $this>pdfLanguage is empty in the action call
class ListIdeas extends ListRecords
{
protected static string $resource = IdeasResource::class;
protected static ?string $title = 'Menu Inspirations';

public string $pdfLanguage = '';

protected function getTableReorderColumn(): ?string
{
return 'position';
}

protected function getActions(): array
{
$default = parent::getActions();

$bespoke = [
Action::make('pdfLanguage')
->action('downloadPdf')
->label('Download')
->icon('heroicon-s-download')
->color('secondary')
->modalHeading('Download Menu Inspirations')
->form([
Radio::make('pdfLanguage')
->label('Which language to you want to download for: ')
->options(
[
'en' => 'English',
'fr' => 'French'
]
)
->default('en')
->inline()
->required(),
]),
];

return array_merge($bespoke, $default);
}

public function downloadPdf()
{
$data = [
$ideas = Ideas::active()->orderBy('position')->get(),
$locale = ''// how do i get handle to pdfLanguage
];

$pdf = Pdf::loadView('filament.resources.ideas.download', $data);
return response()->streamDownload(fn () => print($pdf->output()), "menu_inspirations.pdf");
}
}
class ListIdeas extends ListRecords
{
protected static string $resource = IdeasResource::class;
protected static ?string $title = 'Menu Inspirations';

public string $pdfLanguage = '';

protected function getTableReorderColumn(): ?string
{
return 'position';
}

protected function getActions(): array
{
$default = parent::getActions();

$bespoke = [
Action::make('pdfLanguage')
->action('downloadPdf')
->label('Download')
->icon('heroicon-s-download')
->color('secondary')
->modalHeading('Download Menu Inspirations')
->form([
Radio::make('pdfLanguage')
->label('Which language to you want to download for: ')
->options(
[
'en' => 'English',
'fr' => 'French'
]
)
->default('en')
->inline()
->required(),
]),
];

return array_merge($bespoke, $default);
}

public function downloadPdf()
{
$data = [
$ideas = Ideas::active()->orderBy('position')->get(),
$locale = ''// how do i get handle to pdfLanguage
];

$pdf = Pdf::loadView('filament.resources.ideas.download', $data);
return response()->streamDownload(fn () => print($pdf->output()), "menu_inspirations.pdf");
}
}
TIA
1 Reply
Blackpig
Blackpig8mo ago
Ok I can access it via $this->mountedActionData['pdfLanguage'] unless there is a better accessor for it?