Answer the question
In order to leave comments, you need to log in
How to display the correct data when clicking again?
I use the dateControl kartik widget, but it turns out that when you select one datetime, when you click again, you are transferred to 12/30/1988. In the screenshot, the time frame is indicated for the first time 08/5/2017 9:00:00 AM and when you click on the widget again, it simply transfers to December 1988, although logically it should remain 08/5/2017 9:00:00 AM
Here is how I implemented the code in frontend / cnfig/main.php
use \kartik\datecontrol\Module;
return => [
'modules' => [
'gridview' => ['class' => '\kartik\grid\Module'],
'datecontrol' => [
'class' => 'kartik\datecontrol\Module',
'displaySettings' => [
Module::FORMAT_DATE => 'dd-MM-yyyy',
Module::FORMAT_TIME => 'hh:mm:ss a',
Module::FORMAT_DATETIME => 'php:d M h:m',
],
'saveSettings' => [
Module::FORMAT_DATE => 'php:U',
Module::FORMAT_TIME => 'php:H:i:s',
Module::FORMAT_DATETIME => 'php:Y-m-d H:i:s',
],
'widgetSettings' => [
Module::FORMAT_DATE => [
'class' => 'yii\jui\DatePicker', // example
'options' => [
'dateFormat' => 'php:d-M-Y',
'options' => ['class'=>'form-control'],
]
]
]
],
],
]
use kartik\datecontrol\DateControl;
<?= $form->field($model, 'srok')->widget(
DateControl::className(), [
'language' => 'ru',
'value' => time(),
'type' => DateControl::FORMAT_DATETIME,
'displayFormat' => 'php:d M h:m',
'saveFormat' => 'php:Y-m-d H:i:s',
'widgetOptions' => [
'pluginOptions' => [
'autoclose' => true,
'format' => 'dd.mm.yyyy',
]
]
])->label('Срок');?>
Answer the question
In order to leave comments, you need to log in
Good afternoon.
'datecontrol' => [
'class' => '\kartik\datecontrol\Module',
'displaySettings' => [
Module::FORMAT_DATE => 'd MMMM yyyy',
Module::FORMAT_TIME => 'HH:mm',
Module::FORMAT_DATETIME => 'd MMMM yyyy HH:mm'
],
'autoWidgetSettings' => [
Module::FORMAT_DATETIME => ['pluginOptions' => [
'autoclose' => true,
'todayHighlight' => true,
'startDate' => date('d m Y'),
],
'readonly' => true],
Module::FORMAT_DATE => ['pluginOptions' => [
'autoclose' => true,
'todayHighlight' => true,
'startDate' => date('d m Y'),
],
'readonly' => true],
Module::FORMAT_TIME => ['readonly' => true]
],
'saveSettings' => [
Module::FORMAT_DATETIME => 'php:U',
Module::FORMAT_DATE => 'php:U',
Module::FORMAT_TIME => 'php:U',
],
'ajaxConversion' => true,
]
$form->field($model, 'date_start')->widget(DateControl::className(),
['type' => DateControl::FORMAT_DATE, 'displayTimezone' => 'Europe/Kiev']
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question