Decided to connect to the project widget yii \ jui \ DatePicker http://www.yiiframework.com/doc-2.0/yii-jui-datepicker.html

Added to composer.json (as it is stated in the documentation https://github.com/yiisoft/yii2-jui to the widget) a line:

... "yiisoft/yii2-jui": "~2.0.0" ... 

Updated:

 composer update 

Added to the template design code:

 <?php echo \yii\jui\DatePicker::widget( [ 'name' => 'from_date', 'value' => '', 'language' => 'ru' ] ); ?> 

As a result, input appeared on the page:

 <input type="text" id="w0" name="from_date" value=""> 

And also appeared JS-code:

 <script type="text/javascript">jQuery(document).ready(function () { $('#w0').datepicker($.extend({}, $.datepicker.regional['ru'], {"dateFormat":"M d, yy"})); });</script> 

DatePicker did not work ... And the console displays an error:

jquery.js: 3793 Uncaught TypeError: Cannot read property 'regional' of undefined

enter image description here

  • Are all the scripts connected? <script src="/web/assets/6979d031/jquery.js"></script> <script src="/web/assets/ac9a3336/jquery-ui.js"></script> <script src="/web/assets/ac9a3336/ui/i18n/datepicker-ru.js"></script> - Bookin
  • Yes, these scripts are present - Skim
  • In the correct order, and after them js with a datepicker call? Just a mistake says that $.datepicker does not exist. That is, whether or not jquery-ui on the page, or not yet loaded. Or do you have a duplicate jquery.js , maybe you are on the page somewhere in the manual connect jquery.js? - Bookin

1 answer 1

An example from my project. I think you have an error in the language parameter, there should be ru-RU .

 <?php use yii\jui\DatePicker; echo $form->field($model, 'birthdate')->widget(DatePicker::classname(), [ 'language' => 'ru-Ru', 'dateFormat' => 'yy-MM-dd', 'clientOptions' => [ 'yearRange' => '1956:2016', 'changeMonth' => 'true', 'changeYear' => 'true', 'firstDay' => '1', ] ]); ?>