我在yii2中有一个kartik select2相关下拉列表,我想选择一个值作为默认选择值。
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.calendars.js"></script>
<script type="text/javascript" src="js/jquery.calendars.plus.js"></script>
<link rel="stylesheet" type="text/css" href="css/jquery.calendars.picker.css">
<script type="text/javascript" src="js/jquery.plugin.js"></script>
<script type="text/javascript" src="js/jquery.calendars.picker.js"></script>
如何在下拉列表中选择默认值?
答案 0 :(得分:1)
在控制器中
$EmployeeLeaveModel->EmployeeID = value;
<?= $form->field($EmployeeLeaveModel, 'EmployeeID')->widget(Select2::classname(), [
'data' => $Employee,
'language' => 'en',
'options' => ['placeholder' => 'Select Employee,...'],
]) ?>
或强>
在视图中
recyclerView.sethasFixedSize(true);