Reputation: 1046
Here i like to explain my problem clearly,
This is my code
<?= $form->field($model, 'doa')->widget(
DatePicker::className(), [
'inline' => false,
'clientOptions' => [
'autoclose' => true,
'format' => 'yyyy-m-dd',
'todayHighlight' => true
]
]); ?>
Here once i set the date using datepicker, i need to disable the datepicker or make datepicker as Readonly.
if i try this
<?= $form->field($model, 'doa')->widget(
DatePicker::className(), [
'inline' => false,
'readonly' => !empty($model->doa),
'clientOptions' => [
'autoclose' => true,
'format' => 'yyyy-m-dd',
'todayHighlight' => true
]
]); ?>
am getting error as : Setting unknown property: dosamigos\datepicker\DatePicker::readonly
Upvotes: 0
Views: 7212
Reputation: 83
For 'options' you have to use 'disabled' => 'disabled'
echo DatePicker::widget([
'name' => 'termin',
'id' => 'termin',
'language' => 'cs',
'template' => '{addon}{input}',
'options' => [
'autocomplete'=>'off',
'disabled' => 'disabled'
],
'clientOptions' => [
'autoclose' => true,
'format' => 'dd.mm.yyyy',
'todayHighlight' => true,
]
]);
Upvotes: 0
Reputation: 1
Just setting disabled didn't work for me, so here is my solution:
<?= $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
]
]); ?>
Upvotes: 0
Reputation: 449
try
<?= $form->field($model, 'doa')->widget(
DatePicker::className(), [
'inline' => false,
'disabled' => !empty($model->doa),
'clientOptions' => [
'autoclose' => true,
'format' => 'yyyy-m-dd',
'todayHighlight' => true
]
]); ?>
Upvotes: 1
Reputation: 4160
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'
]
]
); ?>
Upvotes: 3