navbar.blade.php文件中的按钮 每次用户点击编辑按钮时,其通信ID应通过此表格...
<button class="btn btn-primary" data-toggle="modal" data-target="#myModal">Edit</button>
并且此按钮被重定向到此表单
<form action="-----------" method="POST" role="form" class="form-horizontal">
{{ csrf_field() }}
<div class="form-group">
<label for="email" class="col-sm-2 control-label">
Nav ID</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="nav_id" placeholder="nav id" readonly="" />
</div>
</div>
<div class="form-group">
<label for="email" class="col-sm-2 control-label">
Nav Name</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="nav_name" placeholder="nav name" />
</div>
</div>
<div class="form-group">
<label for="exampleInputPassword1" class="col-sm-2 control-label">
Nav Details</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="nav_description" placeholder="nav details" />
</div>
</div>
<div class="row">
<div class="col-sm-2">
</div>
<div class="col-sm-10">
<button type="submit" class="btn btn-primary btn-sm">
Submit</button>
</div>
</div>
</form>
那么如何更新.blade文件中所选ID的记录以及我应该在navbarController.php及其路径文件中写什么
public function edit(Request $request) {
}
}
答案 0 :(得分:1)
这是解决方案
添加&#34;编辑按钮&#34;类到您的按钮并使用alt属性来保持$ ID
<button class="edit-button btn btn-primary" alt="<?=$ID?>" data-toggle="modal" data-target="#myModal">Edit</button>
添加隐藏字段以将$ ID保留在表单中
<input id="id" type="hidden" name="id" value=""/>
当用户单击编辑按钮时,使用@section和@yield编写jquery代码来调整隐藏字段的值。让我们看看https://laravel.io/forum/09-02-2014-using-section-and-yield
@section('javascript')
$("body").on('click','.edit-button',function(){
var activeEditId = $(this).attr('alt');
$("#id").val(activeEditId);
)});
@stop