Is it possible to send an array as a parameter to a function? Searched this online but didn't help me much further. This is what I have :
In my twig I have:
<a id="exporttocsv" href="{{ path('dashboard.index', {'data': tableresults|json_encode}) }}" class="btn btn-default">Export to CSV</a>
And in my Controller:
public function exporttocsvAction(Application $app, Request $request, $data)
{
header("Content-Type: text/csv");
header("Content-Disposition: attachment; filename=test.csv");
header("Pragma: no-cache");
header("Expires: 0");
$output = fopen("php://output", "w");
foreach ($data as $row)
{
fputcsv($output, $row, ',');
}
fclose($output);
exit();
}
But when I click my button, my link changes to something like this and just refreshes:
Is it possible to send an array? Or should I do this with an ajax call and send the data?