我想清楚地解释一下我的问题,
这是我的代码
<?= $form->field($model, 'doa')->widget(
DatePicker::className(), [
'inline' => false,
'clientOptions' => [
'autoclose' => true,
'format' => 'yyyy-m-dd',
'todayHighlight' => true
]
]); ?>
这里一旦我使用datepicker设置日期,我需要禁用datepicker或将datepicker设为Readonly。
如果我试试这个
<?= $form->field($model, 'doa')->widget(
DatePicker::className(), [
'inline' => false,
'readonly' => !empty($model->doa),
'clientOptions' => [
'autoclose' => true,
'format' => 'yyyy-m-dd',
'todayHighlight' => true
]
]); ?>
我收到的错误为:Setting unknown property: dosamigos\datepicker\DatePicker::readonly
答案 0 :(得分:3)
Diable Client Event as: -
<?= $form->field($model, 'doa')->widget(
DatePicker::className(),
[
'inline' => false,
'clientOptions' => [
'autoclose' => true,
'format' => 'yyyy-m-dd',
'todayHighlight' => true,
],
'clientEvents' => [
'changeDate' => false
],
'options' => [
'readonly' => 'readonly'
]
]
); ?>
答案 1 :(得分:1)
尝试
<?= $form->field($model, 'doa')->widget(
DatePicker::className(), [
'inline' => false,
'disabled' => !empty($model->doa),
'clientOptions' => [
'autoclose' => true,
'format' => 'yyyy-m-dd',
'todayHighlight' => true
]
]); ?>
答案 2 :(得分:0)
设置禁用对我来说不起作用,所以这是我的解决方案:
<?= $form->field($model, 'doa')->widget(
DatePicker::className(), [
'inline' => false,
'addon' => false,//To disable addon button with its events
'disabled' => !empty($model->doa),
'clientOptions' => [
'autoclose' => true,
'format' => 'yyyy-m-dd',
'todayHighlight' => true
]
]); ?>