【发布时间】:2017-12-02 07:49:57
【问题描述】:
我希望通过勾选复选框来提交一个在 foreach 循环中有行的表单。当在 foreach 循环之外有一行时,我似乎将 id 数据接收到我的控制器中,但是当它在 foreach 循环之外时,它只是被跳过了。这是我的代码示例?我错过了什么?
<form action="{{ url('/staff') }}" method="POST" role="form" id="form" class="form-horizontal">
{{ csrf_field() }}
@foreach ($items as $item)
<tbody>
<tr>
<td >
{{ $item->first_name }} {{ $item->last_name }}
</td>
<td class="center">
<div class="checkbox-table">
<label>
<input name="item[]" value="{{ $item->id }}" type="checkbox" class="flat-grey">
</label>
</div>
</td>
</tr>
@endforeach
</tbody>
<div>
<button class="btn btn-yellow" type="submit">
Save</i>
</button>
</div>
</form>
【问题讨论】:
标签: php arrays foreach laravel-5.3 laravel-blade