Yii2 中的预检查复选框列表
Pre-Checked CheckboxList in Yii2
这里有 Table mail_for
,在这个 table 我有数据
id email_for
1 Hr
2 Tpa
3 Insurer
4 Client
5 no_reciptents
所以我使用这段代码为这些数据制作了一个复选框列表
<?php
$mail_for = ArrayHelper::map(MailFor::find()->all(),'id','email_for');
echo $form->field($model, 'email_for')->checkboxList($mail_for, array('checked'=>'checked'));
?>
所以,我需要 pre checked
复选框列表 id 5
(no_reciptents)
在 email_for 字段之前分配要预检查的值,如下所示。
$model->email_for = $ValueToBePrechecked;
这里有 Table mail_for
,在这个 table 我有数据
id email_for
1 Hr
2 Tpa
3 Insurer
4 Client
5 no_reciptents
所以我使用这段代码为这些数据制作了一个复选框列表
<?php
$mail_for = ArrayHelper::map(MailFor::find()->all(),'id','email_for');
echo $form->field($model, 'email_for')->checkboxList($mail_for, array('checked'=>'checked'));
?>
所以,我需要 pre checked
复选框列表 id 5
(no_reciptents)
在 email_for 字段之前分配要预检查的值,如下所示。
$model->email_for = $ValueToBePrechecked;