Without seeing your code for the form I'm guessing from the fact you said you are getting %7Bid%7D
that you've missed a set of curly braces.
Laravel 4 Form Model not binding id correctly
-
26-06-2023 - |
Question
I am binding a user model to a form and attaching the id. When i hit submit it places a character code (%7Bid%7D) into the form in place of the id. The model elements bind to the form properly otherwise. If I use firebug to change that code to 1 then it fires fine so I know it is an issue with how the id is binding or set.
What am I doing wrong?
I have the following code pieces:
View
{{ Form::model($user, array('route' => 'users.update', $user->id)) }}
Route that is being set in the form
Route::post('users/{id}/update', array(
'uses' => 'UserController@update',
'as' => 'users.update'
));
Controller Method that calls the form (UserController)
public function edit($id)
{
//
$user = $this->user->find($id);
return View::make('users.edit')->with('user', $user);
}
Solution
OTHER TIPS
I had a similar problem. It was down to a named route that required a parameter.
Route::post('something/new/{id}', array(
'as' => 'something-new-post',
'uses' => 'SomeController@newFunction'
));
I was calling it using
{{ URL::route("something-new-post") }}
with the intention of adding the variable later. What I should have been doing is adding an extra parameter..
{{ URL::route("something-new-post", $data) }}
live and learn..
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow