K
K
Ken Jee2016-09-18 14:54:25
Yii
Ken Jee, 2016-09-18 14:54:25

How to properly connect the yii\jui\DatePicker widget to a Yii2 project?

I decided to connect the yii\jui\DatePicker widget to the project www.yiiframework.com/doc-2.0/yii-jui-datepicker.html
Added it to composer.json (as it says in the documentation https://github.com/yiisoft/yii2- jui to widget) line:

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

Updated:
composer update
Added code to the design template:
<?php

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

?>

As a result, an input appeared on the page:
<input type="text" id="w0" name="from_date" value="">

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

DatePicker didn't work... And an error is displayed in the console:
jquery.js:3793 Uncaught TypeError: Cannot read property 'regional' of undefined

79982465340d4d7eb6087c598d0bd268.jpg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2016-09-18
@webinar

Try clearing the assets folder, you can try without 'language' => 'ru'
But I would take another widget, for example this one:
demos.krajee.com/widget-details/datepicker
or just take
demos.krajee.com/datecontrol which will cover everything possible needs of date manipulations.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question