Simple laravel html form -
how write code in simple html form in laravel blade
{!! form::model($user, [ 'method' => 'put', 'url' => '/edit-account' ]) !!} in controller have method:
public function edit(request $request) { $user = $request->user(); return view('backend.home.edit', compact('user')); }
<form method="post" action="/edit-account"> {{csrf_field()}} <input type="hidden" name="_method" value="put"> </form> explanation
"method" in laravel collective form similar "method" attribute of html form. "url" in laravel collective form "action" attribute of html form.
as there no put, patch , delete method need pass hidden field named "_method" value of "put" updating data.
and anytime while defining html form in application, should include hidden csrf token field in form csrf protection middleware can validate request , here using csrf_field helper generate token field.
Comments
Post a Comment