0

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>
patricksweeney
4,0497 gold badges45 silver badges57 bronze badges
asked May 29, 2015 at 12:04
1
  • Please, fix typos in the title of question Commented May 29, 2015 at 12:18

3 Answers 3

2

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'
 ]);
answered May 29, 2015 at 15:47
Sign up to request clarification or add additional context in comments.

1 Comment

i am not use show function, i user edit.blade.php for html form and then i am sending this form to update function which is in UserController as public function update($id) { $user = User::find($id); $user->name = Request::input('name'); $user->email = Request::input('email'); $user->mobile = Request::input('mobile'); $user->save(); return view('user/index'); }
0

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);
answered May 29, 2015 at 12:06

1 Comment

i am not use show function, i user edit.blade.php for html form and then i am sending this form to update function which is in UserController as public function update($id) { $user = User::find($id); $user->name = Request::input('name'); $user->email = Request::input('email'); $user->mobile = Request::input('mobile'); $user->save(); return view('user/index'); }
0

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>
answered May 29, 2015 at 13:30

2 Comments

i am using action="{{ route(url('/user/'.$user->id) }}" but not working.
Your form is also missing a submit button.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.