I really don’t understand. I’m stuck on this for days and cannot solve!!!
Tried via composer with all instructions and nothing. Tried manually like this and nothing… I don’t know where is the problem…
Installed on folder: vendor/yiisoft/yii2-jui
/vendor/yiisoft/extensions.php
<?php
$vendorDir = dirname(__DIR__);
return array (
'yiisoft/yii2-jui' =>
array (
'name' => 'yiisoft/yii2-jui',
'version' => '2.0.0.0-beta',
'alias' =>
array (
'@yii/jui' => $vendorDir . '/yiisoft/yii2-jui',
),
),
'yiisoft/yii2-bootstrap' =>
array (
'name' => 'yiisoft/yii2-bootstrap',
'version' => '2.1.9999999.9999999-dev',
'alias' =>
array (
'@yii/bootstrap' => $vendorDir . '/yiisoft/yii2-bootstrap',
),
),
'yiisoft/yii2-gii' =>
array (
'name' => 'yiisoft/yii2-gii',
'version' => '2.1.9999999.9999999-dev',
'alias' =>
array (
'@yii/gii' => $vendorDir . '/yiisoft/yii2-gii',
),
),
);
vendor\yiisoft\yii2-jui\JuiAsset.php
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\jui;
use yii\web\AssetBundle;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class JuiAsset extends AssetBundle
{
public $sourcePath = '@bower/jquery-ui';
public $js = [
'jquery-ui.js',
];
public $css = [
'jquery-ui.css',
];
public $depends = [
'yii\web\JqueryAsset',
];
}
Jquery UI installed on folder /bower/jquery-ui
My view step1_form.php
<?php
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use app\models\Cliente;
use yii\jui\DatePicker;
/* @var $this yii\web\View */
/* @var $model app\models\Checkin */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="checkin-form">
<?php $form = ActiveForm::begin(['action' => ['checkin/step2']]); ?>
<?= $form->field($model, 'cliente_id')
->dropDownList(
ArrayHelper::map(Cliente::find()->orderBy('nome')->all(), 'id', 'nome'),
['prompt'=>'', 'class' => 'form-control select2'] // options
);
?>
<?php
echo DatePicker::widget([
'model' => $model,
'attribute' => 'dt_checkin',
//'language' => 'ru',
//'dateFormat' => 'yyyy-MM-dd',
]);
?>
<?= $form->field($model, 'dt_checkin')->textInput() ?>
<?= $form->field($model, 'dt_checkout_estimado')->textInput() ?>
<div class="form-group">
<?= Html::submitButton('Avançar >', ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
ERROR!!
Always the same error:
PHP Fatal Error – yii\base\ErrorException
Class 'yii\jui\DatePicker' not found
What am I missing? HELP!
Partagas:
Installing Yii2-JUI via Composer I got error:
"…no matching package found". So I decided to install Yii2-jui manually.
So how I did it…
go to github.com/yiisoft/yii2-jui and dowload zip (yii2-jui-master.zip)
Unpack zip to vendor\yiisoft\, so I got vendor\yiisoft\yii2-jui\
Modify vendor\yiisoft\extensions.php as follows (added):
'yiisoft/yii2-jui' =>
array (
'name' => 'yiisoft/yii2-jui',
'version' => '2.0.0.0-beta',
'alias' =>
array (
'@yii/jui' => $vendorDir . '/yiisoft/yii2-jui',
),
),
Modify vendor\yiisoft\yii2-jui\JuiAsset.php as follows:
class JuiAsset extends AssetBundle
{
public $sourcePath = '@bower/jquery-ui';
public $js = [
'jquery-ui.js',
];
public $css = [
'jquery-ui.css', // the problem was in this path
];
public $depends = [
'yii\web\JqueryAsset',
];
}
Go to www.jqueryui.com/download/ and dowload jQuery UI
for example jquery-ui-1.11.4.custom.zip
Unpack zip to vendor\bower\, so I got vendor\bower\jquery-ui\
In view-file where you gonna use widget use namespace, for example:
use yii\jui\DatePicker;
And include widget (as shown at yiiframework.com/doc-2.0/ext-jui-index.html )
For example:
echo DatePicker::widget([
'model' => $model,
'attribute' => 'from_date',
//'language' => 'ru',
//'dateFormat' => 'yyyy-MM-dd',
]);