php - Attempt to update users table generates MethodNotAllowedHttpException, Laravel-4 -
php - Attempt to update users table generates MethodNotAllowedHttpException, Laravel-4 -
userscontroller:
public function update($id) { if( ! $this->user->isvalid(input::all())) { homecoming redirect::back()->withinput()->witherrors($this->user->errors); } $user = $this->user->find($id); $user->save(); homecoming redirect::route('users.index'); } route:
route::resource('users','userscontroller'); model:
protected $table = 'users' edit.blade.php:
{{ form::model($user, array('route'=>array('users.update','$user'=>'id'))) }} i notice not generate "put" action. page source:
<form method="post" action="https://zocios.com/users/id" accept-charset="utf-8"><input name="_token" type="hidden" value="..."> hitting update user button gets me:
exception \ methodnotallowedhttpexception is problem "$user->save();"? else i'm doing wrong? thanks!
you need specify method:
{{ form::model($user, array('method' => 'put', 'route'=>array('users.update','$user'=>'id'))) }} there no other method get , post accepted (despite specs), framework job of identyfying hidden input in form _method create work.
php forms laravel-4
Comments
Post a Comment