YII2在使用activeForm设置默认值

activeForm设置默认值
input:
<?= $form->field($model,'code')->label('国别码')->input('text',['value'=>'ceshi']); ?>
CheckBox:
先在控制器中设置 $model->type = 1
再在视图中<?= $form->field($model,'type')->dropDownList(['1'=>'best','2'=>'better','3'=>"well"],['prompt'=>'请选择']); ?>
dropDownList
先在控制器中设置 $model->items = 'a';
再在视图中<?= $form->field($model, 'items')->checkboxList(['a' => 'Item A', 'b' => 'Item B', 'c' => 'Item C']);?>
原文地址:https://www.cnblogs.com/jjchi/p/9398289.html