Error using dateFormat from jui/datePicker

Hello guys, I have the following DatePicker (nothing unusual here):


<?=$form->field($pessoa_has_infracao, 'data')->widget(DatePicker::classname(),[

                    'name' => 'to_date',

                    'language' => 'pt-BR',

                    'clientOptions' => [

                        'dateFormat' => 'dd/MM/yyyy'

                    ],

                    'options' => [

                        'language' => 'pt-BR',

                        'class' => 'round form-control',

                        'placeholder' => "Data"

                    ],

                ])->label(false); ?>

The problem is that the format rendered is MM/dd/yyyy and the language is English. I know I might have plaaced the ‘languange’ and ‘dateFormat’ in the wrong place, but I have tried them both inside of clientOptions and options as well.

I have heard somewhere that I should place dateFormat before anything else and I also tried this approach which resulted in an error.

Can anyone help me out?

Hi Ian Pierre,




<?= $form->field($pessoa_has_infracao, 'data')->widget(\yii\jui\DatePicker::classname(), [

      'name' => 'to_date',

      'language' => 'pt-BR',

      'dateFormat' => 'dd/MM/yyyy',

      'options' => [

          'class' => 'round form-control',

          'placeholder' => "Data"

      ],

]) ?>



That is correct.

But can you check if exist this file datepicker-pt-BR.js in your Application.

It is under "vendor/bower/jquery-ui/ui/i18n/datepicker-pt-BR.js"

The following is a snippet from one of my working apps.




<?php echo $form->field($model, 'claimed_at', ['enableClientValidation' => false,])

    ->widget(DatePicker::className(), [

       'options' => ['class' => 'form-control'],

       'language' => 'ja',

       'dateFormat' => 'yyyy-MM-dd',

       'clientOptions' => [

           'changeMonth' => true,

           'changeYear' => true,

           'showOtherMonths' => true,

           'selectOtherMonths' => true,

           'showButtonPanel' => true,

       ],

   ]);

?>



‘language’ and ‘dateFormat’ are in the first level of the configuration array.

And, it may not be relevant, ‘name’ should not appear in the array, since we are using a model and an attribute of it( ‘claimed_at’ in my case and ‘data’ in yours).