Reputation: 27
I want to submit a form in laravel 5 but it does not call the update function.
<form class="form-horizontal", role="form" method="patch" action{{url('/user/'.$user->id) }}">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="form-group">
<label class="col-md-4 control-label">Name</label>
<div class="col-md-6">
<input type="text" class="form-control" name="name" value="{{ $user- >name }}">
</div>
</div>
</form>
Upvotes: 0
Views: 2960
Reputation: 3257
The action
attribute is not complete, should be action="..."
You can also use route instead of url e.g.
In blade:
<form class="form-horizontal", role="form" method="patch" action="{{ route('user.show') }}">
In routes.php:
Route::get('user/{id}', [
'uses' => 'UsersController@action',
'as' => 'user.show'
]);
Upvotes: 2
Reputation: 948
Your html is invalid, you are missing the action
attribute. HTML forms should generally take the form:
<form action="where/form/submits/to" method="form-method"> ... </form>
see this for details on the form element. In your case that will is should be like:
<form class="form-horizontal", role="form" method="patch" action="{{url('/user/'.$user->id) }}"> ... </form>
Upvotes: 0
Reputation: 282
The action is incorrect. Missing = and beginning ". You also have a , after class. Not valid html.
If you want to pass parameters to an URL then maybe you should consider this.
url('foo/bar', $parameters = [], $secure = null);
Upvotes: 0