php - MethodNotAllowedHttpException on resource defined method Laravel-4 -
i created simple form use submit button rather link open edit users page. using link works perfectly, form button fails , yields methodnotallowedhttpexception though method ("edit") defined in userscontroller resource , otherwise works fine.
route:
route::resource('users','userscontroller');
userscontroller:
public function edit($id) { $user = $this->user->find($id); return view::make('users.edit')->with('user',$user); }
show.blade.php:
<!-- works fine: --> {{ link_to_route('users.edit', ("edit: " .$user->first_name." ".$user->last_name), $user->id) }} <!-- doesn't work, , yields method not allowed exception: --> {{ form::open(array('route' => array('users.edit',$user->id))) }} {{ form::submit('edit user', array('class'=>'button')) }} {{ form::close() }}
thanks.
when form::open()
, defaults using post
request method. when create route::resource()
, edit
method takes get
request.
to make work through form, you'll need open additional parameter, this:
{{ form::open(array('route' => array('users.edit',$user->id), 'method' => 'get')) }}
Comments
Post a Comment