P
P
Proncer2017-01-26 22:03:36
Yii
Proncer, 2017-01-26 22:03:36

Why can't the days be displayed in the kartik\date\DatePicker widget?

Can you please tell me why the calendar may not be displayed in the kartik\date\DatePicker widget? It looks like this on the page:
5a6ebee5ae0d4e379c71aa8e85b0e009.png
In the console:

<div class="datepicker-days" style="display:none"></div>

File (view):
use \kartik\form\ActiveForm;
use \kartik\date\DatePicker;

$form = ActiveForm::begin([
                    'id' => 'profile-form',
                    'options' => ['class' => 'form-horizontal'],
                    'fieldConfig' => [
                        'template' => "{label}\n<div class=\"col-lg-9\">{input}</div>\n<div class=\"col-sm-offset-3 col-lg-9\">{error}\n{hint}</div>",
                        'labelOptions' => ['class' => 'col-lg-3 control-label'],
                    ],
                    'enableAjaxValidation' => true,
                    'enableClientValidation' => false,
                    'validateOnBlur' => false,
                ]);

echo $form->field($model, 'date_1')->widget(DatePicker::classname(), [
    'options' => ['placeholder' => 'Enter birth date ...'],
    'pluginOptions' => [
        'autoclose'=>true
    ]
]);

ActiveForm::end();

I understand that the problem is that this element has display:none , but why does it not change? Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2017-01-26
@slo_nik

Good evening.
Did you set up the widget, read about all kinds of settings on the official website?
Set better DateControl
In View:

<?= $form->field($model, 'date')->widget(DateControl::className(),
                                                        ['type' => DateControl::FORMAT_DATE]
                                                      ) ?>

In the config file:
'datecontrol' =>  [
            'class' => '\kartik\datecontrol\Module',
            'displaySettings' => [
                Module::FORMAT_DATE => 'd MMMM yyyy',
                Module::FORMAT_TIME => 'hh:mm',
                Module::FORMAT_DATETIME => 'dd-MM-yyyy hh:mm:ss a',
            ],
            'autoWidgetSettings' => [
                Module::FORMAT_DATE => ['pluginOptions' => [
                                                 'autoclose' => true,
                                                 'todayHighlight' => true,
                                                 'startDate' => 'current',
                                       ],
                                        'readonly' => true],
                Module::FORMAT_TIME => ['readonly' => true]
            ],
            'saveSettings' => [
                Module::FORMAT_DATE => 'php:U',
               // Module::FORMAT_TIME => 'php:u'
            ],
            'ajaxConversion' => false,
        ]

Well, or play around with the DatePicker settings, but DateControl is better

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question