默认选中0,选中开通
<?php if($model->isNewRecord){$model->is_suspend = 0;$model->is_closed = 0;}?>
<?= $form->field($model, 'is_suspend')->radioList(['1' => '是', '0' => '否'], ['style' => 'padding-top: 5px;'])->label('暂停') ?>
<?= $form->field($model, 'is_closed')->radioList(['1' => '是 ', '0' => '否'], ['style' => 'padding-top: 5px;'])->label('关闭') ?>
复选框默认选中,增加隐藏框,如果选中了,下面的值会覆盖上面的值。
<input type="hidden" name="CommunityFeature[<?= $key['field'] ?>]" value="0"/>
<input type="checkbox" name="CommunityFeature[<?= $key['field'] ?>]" value="1" id="CommunityFeature[<?= $key['field'] ?>]" checked />