**已关闭。**此问题为not reproducible or was caused by typos。目前不接受答案。
这个问题是由一个打字错误或一个无法再重现的问题引起的。虽然类似的问题在这里可能是on-topic,但这个问题的解决方式不太可能帮助未来的读者。
两年前就关门了。
Improve this question
我用Yii2创建了一个checkboxList,我需要给每个checkbox分配一个id(这样我就可以在jQuery中使用它了),但是我不知道怎么做。
<?
$cities ArrayHelper::map(Cities::find()->all(), 'city_id', 'city_name');
echo Html::checkboxList(
'cities'
null,
$cities,
[
'itemOptions' => [
'id' => $cities->city_id // MY PROBLEM IS IN THIS LINE,
],
]
) ?>
这是错误:
2条答案
按热度按时间1rhkuytd1#
如果你在这里检查文档,你可以给
$options
的(yii\helpers\Html::checkboxList
的第四个参数)item
键传递一个匿名函数,在这里你可以显式地指定HTML呈现结构到你的复选框列表,如下所示:bfnvny8b2#
应该是