2018-06-06 14:40:18 1977次浏览 1条回答 0 悬赏 10 金钱
<?= $form->field($product, 'label')->CheckBoxList(Pag::allPag(),array(1,2)) ?>

allPag() 的数据结构是这样的

array(2) {
  ["1"]=>
  string(12) "四大四大"
  ["2"]=>
  string(9) "是的打"
}

我也搜到几个差不多的回答 他们都说这样是可以选中的 但是我这样写不行

最佳答案

  • 小叮当的肚兜 发布于 2018-06-06 16:08 举报
    <?= $form->field($model, 'username')->CheckBoxList([1=>'test1',2=>'test2'],['value'=>[1,2]]) ?>
    

    多看看源码,我找了几分钟就看到了

     protected static function activeListInput($type, $model, $attribute, $items, $options = [])
        {
            $name = isset($options['name']) ? $options['name'] : static::getInputName($model, $attribute);
            $selection = isset($options['value']) ? $options['value'] : static::getAttributeValue($model, $attribute);
            if (!array_key_exists('unselect', $options)) {
                $options['unselect'] = '';
            }
            if (!array_key_exists('id', $options)) {
                $options['id'] = static::getInputId($model, $attribute);
            }
    
            return static::$type($name, $selection, $items, $options);
        }
    
    1 条回复
    回复于 2018-06-06 16:59 回复

    谢谢啦 我是不大看源码==

    没有找到数据。
您需要登录后才可以回答。登录 | 立即注册
jsonrecode
见习主管

jsonrecode 南京

注册时间:2017-09-02
最后登录:2019-11-15
在线时长:10小时11分
  • 粉丝2
  • 金钱300
  • 威望0
  • 积分400

热门问题