Class 'yii\jui\DatePicker' not found

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…

  1. go to github.com/yiisoft/yii2-jui and dowload zip (yii2-jui-master.zip)

  2. Unpack zip to vendor\yiisoft\, so I got vendor\yiisoft\yii2-jui\

  3. 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',

    ),

  ),



  1. 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',

    ];

}



  1. Go to www.jqueryui.com/download/ and dowload jQuery UI

for example jquery-ui-1.11.4.custom.zip

  1. Unpack zip to vendor\bower\, so I got vendor\bower\jquery-ui\

  2. In view-file where you gonna use widget use namespace, for example:

use yii\jui\DatePicker;

  1. 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',

]);



hi buddy

thats works fine nice article with explanation thanks buddy

This was exactly was I was looking for, and perfectly explained step by step.

Muchas gracias, tenias días tratando de instalar el complemento, seguí los pasos y funciono perfecto.

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…

  1. Installed on folder: vendor/yiisoft/yii2-jui

  2. /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',

    ),

  ),

);



  1. 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',

    ];

}



  1. Jquery UI installed on folder /bower/jquery-ui

  2. 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!

You have to get your Composer up and running!

Please create a new topic in the ‘installation’ forum, if you have issues with this command:


php composer.phar require --prefer-dist yiisoft/yii2-jui

You might not want to solve this now, and prefer to hack around, but you know you will need to fix this sooner or later, so why not sooner?

Like, right now? :)

Also, this topic is 2 years old