jui DatePicker client option not working with activeform

Hi all,

I am new to Yii framework and found something very strange so I came here for some help!

[b]Installed Version: Yii2

Environment: XAMPP with MAC OSX[/b]

I was developing a form with datepicker, and I installed the yii\jui\DatePicker trying to make a birthday field with datepicker.

The code I am using is like this:

$form->field($model,'birthday')->widget(DatePicker::className(),['clientOptions' => ['dateFormat' => 'yy-mm-dd', 'defaultDate' => '2014-01-01']]);

There is no error or exception occured but it looks wrong, the dateFormat and the defaultDate is totally different from what I expected.

Attachment 1: when I use form to update a record, the dateformat is incorrect

Attachment 2: and when I use form to create a record, the defaultdate is also incorrect

I tried to add a datepicker without using ActiveForm, then the dateFormat showed correctly.

I really don’t know why, is there anything incompatible between ActiveForm and DatePicker?

PS there is also a slight difference (the left padding/margin) between the default datepicker and my generated one. I don’t know why that happens.

Attachment 3: a default standard datepicker I found from the internet

Please, any one help me, this bug drives me crazy!

I think you are using Yii2 if u did not have use the yii\jui\DatePicker in php file u have to use it like this

$form->field($model,‘birthday’)->widget(yii\jui\DatePicker::className(),[‘clientOptions’ => [‘dateFormat’ => ‘yy-mm-dd’, ‘defaultDate’ => ‘2014-01-01’]])->textInput([‘placeholder’ => ‘Class Date’]);

Hope fully it will work fine.

Thank you for your help, the styling fixed after I use this code but the default date and dateformat is still wrong after I click the calendar.

You can select any format you want by mentioning it in "dateFormat" option.

$this->widget(‘zii.widgets.jui.CJuiDatePicker’, array(

                   'model' => $model,

                   'attribute' => 'birthday',

                    'options' => array(

                    'dateFormat' => 'yy-mm-dd',     // format of "2012-12-25"




This will work perfectly.

Thank all of you.

I finally worked out why.

I installed a extension and this extension was conflicting with the default jui\DatePicker.

Hi Minamiyoru

Can you share your code it is not working in my case also

my composer file have

"minimum-stability": "stable",

"require": {

    "php": ">=5.4.0",

    "yiisoft/yii2": "*",

    "yiisoft/yii2-bootstrap": "*",

    "yiisoft/yii2-swiftmailer": "*",

"yiisoft/yii2-jui": "*"


"require-dev": {

    "yiisoft/yii2-codeception": "*",

    "yiisoft/yii2-debug": "*",

    "yiisoft/yii2-gii": "*",

    "yiisoft/yii2-faker": "*"


Hi all

I got the solution the widget has a property dateFormat which will be used as its dateFormat instead of dateFormat of clientOptions

Other properties are also listed here