如何在yii2 RadioList()中预选/选中默认单选按钮?

疯狂的头骨

我希望在表单中预先选择单选按钮。

 <?= $form->field($model, 'config')->radioList(['1'=>'Automatic Entry',2=>'Manual Entry'])
     ->label('Barcode/Book No Generation'); ?>
塔莱布

预选值取自$model->config这意味着您应该将该属性设置为要预先选择的值:

$model->config = '1';
$form->field($model, 'config')->radioList([
    '1' => 'Automatic Entry',
    '2' => 'Manual Entry',
]);

有关的文档在ActiveForm类中。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章