wang4142 2016-07-18 22:58:39 2356次浏览 0条回复 0 1 0

单复选框选中: Model中: 增加 allow 属性。

controller中 设置

$model->allow = 1

view:

<?= $form->field($model, 'allow')->checkbox(['label' => '允许']) ?>

多复选款选中: Model中: 增加 check_sports 属性,必须是array类型。

controller中:

$model->check_sports['basketball'] = 'basketball';
$model->check_sports['football'] = 'football';
$model->check_sports['volleyball'] = 'volleyball';
$sports = array('basketball' => '篮球', 'football' => '足球', 'volleyball'=>'排球');

或者

$model->check_sports['basketball'] = '0';
$model->check_sports['football'] = '1';
$model->check_sports['volleyball'] = '2';
$sports = array('basketball', 'football', 'volleyball');

view:

<?= $form->field($model, 'check_sports')->checkboxList($sports) ?>
觉得很赞
    没有找到数据。
您需要登录后才可以回复。登录 | 立即注册