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']);?>
posted @ 2018-07-31 21:11  坚持!!  阅读(2189)  评论(0编辑  收藏  举报