如何在activeForm表单属性中附加序列号

时间:2019-09-14 08:13:59

标签: yii2

尝试显示表格中的问题,我想在该问题之前显示序列号。

我尝试过,但是我在一行中得到数字,而问题是另一行。
EX:
enter image description here

<?= $index+1 . $form->field($practiceTest, "[$index]question")->textarea(['readonly'=> true]) ?>

任何人都可以提出类似问题后如何显示数字的想法。
例如:1.问题

1 个答案:

答案 0 :(得分:1)

如果需要获取计算出的数字,可以尝试使用“顺序列表”。

<ol type="1">
  <!-- I guess here you iterate to get index -->
  <li>
      <?= $form->field($practiceTest, "[$index]question")->textarea(['readonly'=> true]) ?>
  </li>

 <!-- Finish iteration -->
</ol>

希望这会有所帮助