首页 > 解决方案 > 如何解决PHP中for循环准备的输入和标签的索引问题?

问题描述

我正在做我在 homepage.blade 文件中使用 for 循环创建的结构。我有这样的问题。假设我创建了 5 个输入。创建结构后按第 5 个标签时,始终激活 1.input。我该如何解决这个问题?

主页.blade.php

 <h4>Checkbox</h4>
  @include('items.checkbox')
  @include('items.checkbox', array('error' => true))
  @include('items.checkbox', array('label' => 'Inline Centered', 'labelClass'=> 'label-centered'))

复选框.blade.php

<fieldset class="form-group checkbox @if (!empty($width)){{$width}}@endif @if(!empty($labelClass)) {{$labelClass}} @endif">
  <input id="checkbox{{$i}}" type="checkbox" placeholder="Option text" />
  <div class="wrapper">
    <label for="checkbox{{$i}}">@if (!empty($label)) {{$label}} @else Checkbox @endif *</label>
    <small>Helper text goes here</small>
  </div>
</fieldset>

标签: phphtml

解决方案


推荐阅读