【发布时间】:2020-05-31 11:50:21
【问题描述】:
我使用 Laravel 应用程序,我们在数据表上显示数据。当我们使用 Foreach 使用 Bootstrap 模态框更新数据时,只获取表中的最后一个数据。
我们链接的按钮:
@foreach($patients as $patient)<br>
<li>
<button type="button"
class="btn btn-primary btn-sm"
data-toggle="modal"
data-target="#myModal{{$patient->patient_id}}">Update Fee</button>
</li>
@endforeach
模态框:
<div id="myModal{{$patient->patient_id}}" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title"><span class="glyphicon glyphicon-edit"></span> Edit Fee</h4>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<label> Total Fee</label>
<input type="text" name="fee" class="form-control" readonly value="{{$patient->Fee->Fee}}" />
<input type="hidden" name="id" class="form-control">
</div>
</form>
</div>
</div>
</div>
</div>
【问题讨论】:
-
你能给我们看一些代码吗?让我们知道你做了什么?还有什么问题
-
你在循环模式吗?
-
是的,循环引导模型框,但只获取最后一个ID而不是全部,如何解决它