Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form::open with a route cannot pass parameters #491

Closed
wingsline opened this issue Mar 4, 2013 · 4 comments
Closed

Form::open with a route cannot pass parameters #491

wingsline opened this issue Mar 4, 2013 · 4 comments

Comments

@wingsline
Copy link

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);
@taylorotwell
Copy link
Member

Fixed. Good catch!

@fanals
Copy link

fanals commented May 26, 2014

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))))}}

@bahoo
Copy link

bahoo commented May 28, 2014

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

@fanals
Copy link

fanals commented Jun 2, 2014

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))) }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants