Framework: Form::open with a route cannot pass parameters

Created on 4 Mar 2013  路  4Comments  路  Source: laravel/framework

I don't think that there is a way to pass route parameters to a Form::open that uses routes.

My proposal is that we can pass an array for the route key's value like this:

Form::open (array ('method'=>'put', 'route'=>array($routeName [,params...]))

and in the Illuminate\Html\FormBuilder's getAction() 537:

$routeParams = (array) $options['route'];
$route = array_shift($routeParams);
return $this->url->route($route, $routeParams);

Most helpful comment

Thanks @bahoo

I have no idea why I used a colon. So yes it works just by using:

{{ Form::open(array('route' => array('kpi.settings.save', 1))) }}

All 4 comments

Fixed. Good catch!

What about if my route looks like that ?

Route::post('/kpi/:id/settings', array('as' => 'kpi.settings.save', 'uses' => 'KpiController@saveSettings'));

This doesn't seem to work:

{{Form::open(array('route' => array('kpi.settings.save', array('id' => 1))))}}

@fanals, do you need to use {id} instead of :id? I'm new to Laravel but haven't seen that syntax using a colon.

Thanks @bahoo

I have no idea why I used a colon. So yes it works just by using:

{{ Form::open(array('route' => array('kpi.settings.save', 1))) }}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

felixsanz picture felixsanz  路  3Comments

klimentLambevski picture klimentLambevski  路  3Comments

jackmu95 picture jackmu95  路  3Comments

JamborJan picture JamborJan  路  3Comments

Anahkiasen picture Anahkiasen  路  3Comments