David
David

Reputation: 5937

Laravel: Forms on pages with url parameters

I have a routes generated as below and want to put a form on the page:

Route::get('suppliers/dashboards/{supplier}', ['uses'=>'SuppliersDashInvoiceController@index'])->middleware('auth');

Route::post('suppliers/dashboards/{supplier}', array( 'before' => 'csrf', 'uses' => 'SuppliersDashInvoiceController@iprocess'))->middleware('auth');

But when using the Form laravel helper, I get an error relating to

Missing required parameters for [Route: ] [URI: suppliers/dashboards/{supplier}]

Form helper:

{!! Form::open(array('action' => array('SuppliersDashInvoiceController@iprocess'))) !!}

Does anyone know how to pass the {supplier} parameter to the form open helper, its not documented in the laravel docs.

Upvotes: 4

Views: 1428

Answers (1)

Alexey Mezenin
Alexey Mezenin

Reputation: 163788

You need to pass parameter, for example:

{!! Form::open(['action' => ['SuppliersDashInvoiceController@iprocess', $supplier->id]]) !!}

https://laravelcollective.com/docs/5.2/html#opening-a-form

Upvotes: 5

Related Questions