Reputation: 39
Hello I have installed date time picker from "https://github.com/2amigos/yii2-date-time-picker-widget"
I have put this into vendor/amigos/yii2-date-time-picker-widget-master
I have added following lines in my composer.json "amigos/yii2-date-time-picker-widget" : "*" in require section
so it is finally
"require": {
"php": ">=5.4.0",
"yiisoft/yii2": "*",
"yiisoft/yii2-bootstrap": "*",
"yiisoft/yii2-swiftmailer": "*",
"amigos/yii2-date-time-picker-widget" : "*"
},
but when I write following code,
<?= DateTimePicker::widget([
'attribute' => 'created_at',
'language' => 'es',
'size' => 'ms',
'clientOptions' => [
'autoclose' => true,
'format' => 'dd MM yyyy - HH:ii P',
'todayBtn' => true
] ]);?>
It says "Class 'DateTimePicker' not found"
Upvotes: 1
Views: 5163
Reputation: 857
I suggest use the HTML DatePicker, it doesn't have problems and its easily to use
<?= $form->field($model, 'date_of_birth')->textField(['type' => 'date']);?>
Upvotes: 0
Reputation: 1315
STEP -1 Run this command on Terminal at Project main folder ---->curl -s http://getcomposer.org/installer | php
STEP -2 Successfully installation after run this command --->php composer.phar require kartik-v/yii2-widget-datepicker "*"
you can see this contant in advanced->composer.jason file
"kartik-v/yii2-widget-datepicker": "*"
If you can't see , you can missing some...
STEP -3 Define this library in views-> _form.php use kartik\date\DatePicker;
STEP -4 And last define this given below code in your form at date field
<?= $form->field($model, 'xyz_field')->widget(DatePicker::ClassName(),
[
'name' => 'check_issue_date',
// 'value' => date('d-M-Y', strtotime('+2 days')),
'options' => ['placeholder' => 'Select issue date ...'],
'pluginOptions' => [
'format' => 'yyyy/dd/mm',
'todayHighlight' => true
]
]);?>
Upvotes: 0
Reputation: 3864
for me it is working fine, it looks like you are missing some dependency.
So I think you should update Yii using composer(if composer is installed) for example if you are using windows then go to ur project directory in command prompt and run
composer update --prefer-dist
This should update all the dependencies include in your composer.json.
2amigos
instead of just amigos
in every places please try changing the folder
name if that works.Upvotes: 3
Reputation: 495
How did you installed it? Don't try to download it and copy it into vendor.
https://github.com/2amigos/yii2-date-time-picker-widget
Installation
The preferred way to install this extension is through composer.
Either run
composer require 2amigos/yii2-date-time-picker-widget:~1.0
or add
"2amigos/yii2-date-time-picker-widget" : "~1.0"
to the require section of your application's composer.json file. run
composer install
Upvotes: 0
Reputation: 61
Reference: https://github.com/2amigos/yii2-date-time-picker-widget/issues/9#issuecomment-156999145
As bootstrap-datetimepicker is not registered in packagist.org, it is showing this error.
We can do following: Steps:
Install smalot-bootstrap-datetimepicker#2.3.1 using following command
bower install smalot-bootstrap-datetimepicker#2.3.1
This will copy required files in \vendor\bower\smalot-bootstrap-datetimepicker directory.
Clone https://github.com/2amigos/yii2-date-time-picker-widget.git
Remove "bower-asset/smalot-bootstrap-datetimepicker": "2.3.1"
from composer.json.
It should look like this after removing
"require": {
"yiisoft/yii2": "~2.0",
"yiisoft/yii2-bootstrap": "~2.0.0"
},
Commit changes using
git add .
git commit -m "remove dependency."
Update yii2's composer.json to following:
"repositories": [
{
"type":"vcs",
"url":"file://D:\\programs\\xampp\\htdocs\\ppd\\packages\\yii2-date-time-picker-widget-master"
}
],
"require": {
...
"2amigos/yii2-date-time-picker-widget": "dev-master"
},
url
according to path where you have cloned repo.run composer update --prefer-source
.
Now datetimepicker widget is installed.
Upvotes: 0
Reputation: 177
try adding
"2amigos/yii2-date-time-picker-widget" : "~1.0"
to composer.json file and update composer using
php composer.phar update
Upvotes: 0
Reputation: 1
Change it to right name:
2amigos/yii2-date-time-picker-widget
And then you have to update your autoloader:
composer dump-autoload
Upvotes: 0