-1
I’m trying to pass an array of mine view for a controller (it will generate a pdf) in Laravel. I know there’s a chance I could do it this way:
<form class="form-horizontal" method="get" action={{route('pdf.relatorioPessoa',$dataform['nom_nome'],$dataform['nom_endereco'],$dataform['nom_cidade'])}}>
<button type="submit">Gerar Relatório</button>
</form>
Meanwhile this array is huge, has at least 20 fields. I would have to create a parameter for each of them in the route, plus validate in the controller if they can be null. There’s no way I can pass the array all along the route?
I’ve tried changing the route part to:
{{route('pdf.relatorioPessoa',[$dataform])}}
And it turns out: Errorexception: Array to string Conversion
And without the [] says I need to pass a parameter as if nothing is passing.
How are you receiving the parameter in
controller
?– ThRnk
Just like this in the controller: public Function reportPessoa($array){}, already on the route is Route::get('/pdf/person/{array}','pdfController@reportPessoa')->name('pdf.reportPessoa');
– Paulo Martins
And if you use the
request
? https://laravel.com/docs/8.x/requests– ThRnk
I tried, but the command does not reach the control. The error occurs in the parameter passage. These are the last two errors cited, conversion from array to string or just talk that has no parameter. I think maybe there is no way to pass an integer array per parameter even...
– Paulo Martins