php - Passing variable from button to controller Laravel -
i having little routing problem in laravel 5.2. have result page shows detailed information personnel. button, when enabled, generates pdf page. passing variables has been problem close now! public code elaborate.
result page
<form action="generatepdfpage" method="get"> <button type="submit" class="btn btn-default">generate pdf!</button> </form>
routes.php
route::get('/dashboard/result/generatepdfpage', 'resultcontroller@generatepdfc');
generatepdfc controller
public function generatepdfc(){ $id_array_implode = "hallo"; $pdf= pdf::loadview('generatepdf', ["test"=>$id_array_implode])->setpaper('a4', 'landscape'); return $pdf->stream('invoice.pdf'); }
so, on result page using array ($id_array) search database matching records. need pass variable onto generatepdfc controller, can pass again loadview function!
could please me out? :-)
when you're using get
method, can this:
<a href="{{ route('route.name', $parameter) }}"> <button type="submit" class="btn btn-default">generate pdf!</button> </a>
for other methods can use (this 1 delete
method):
<form method="post" action="{{ route('route.name', $parameter) }}" accept-charset="utf-8"> <input name="_method" type="hidden" value="delete"> {{ csrf_field() }} <button type="submit" class="btn btn-sm btn-default">generate pdf!</button> <input type="hidden" value="somevariable" /> </form>
to variable, use this:
public function generatepdf(request $request) { $somevariable = $request->somevariable;
Comments
Post a Comment