3

我已经浏览过类似的帖子,SO但没有什么对我有用,也没有找到相关的答案。即使它没有更新数据。

{!! Form::model($editClient, [ 'method' => 'PATCH','route' => ['clients.update', $editClient->id],'class' => 'form-horizontal', 'id'=>'edit-client' ]) !!}

@include('clients._form')

我使用表格作为partial

路线:

Route::resource('clients', 'ClientController');

控制器方法:

public function edit($id)
{
    $editClient = User::findOrFail($id);
    return view('clients.edit', compact('editClient'));
}

HTML:

<div class="form-group">
    <label class="control-label col-sm-2" for="username">Username:</label>
        <div class="col-sm-10">
        <input type="text" class="form-control" id="email" name="user_name" placeholder="Enter Username">
        </div>
   </div>
<div class="form-group">
    <label class="control-label col-sm-2" for="email">Email:</label>
        <div class="col-sm-10">
        <input type="email" class="form-control" id="email" name="email" placeholder="Enter email">
</div>
  </div>
 <div class="form-group">
    <label class="control-label col-sm-2" for="pwd">Password:</label>
    <div class="col-sm-10"> 
    <input type="password" class="form-control" id="pwd" name="password" placeholder="Enter password">
    </div>
  </div>

<div class="form-group">
  <label class="control-label col-sm-2" for="contact">Contact Number:     </label>
<div class="col-sm-10"> 
<input type="number" class="form-control" id="contact" name="contact" placeholder="Enter Contact Number">
</div>
   </div>
<div class="form-group"> 
    <div class="col-sm-offset-2 col-sm-10">
    <button type="submit" class="btn btn-default">Submit</button>
   </div>
</div>
</form>
4

1 回答 1

0

来自表单模型绑定的 Laravel Collective 文档(https://laravelcollective.com/docs/5.4/html#form-model-binding):

{{ Form::model($user, ['route' => ['user.update', $user->id]]) }}

你有 $editClient 而我认为你的模型可能是 $client

于 2017-10-07T08:31:01.123 回答