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);
}
从您说您得到%7Bid%7D
的事实来看,我没有看到表格的代码,而您错过了一组花括号。
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..
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.