I
I
Igor Braduloff2017-06-17 15:03:40
Yii
Igor Braduloff, 2017-06-17 15:03:40

Class 'kartik\select2\Select2' not found?

Tell me why the error Class 'kartik\select2\Select2' not found
falls out the code below:

<?php

use kartik\select2\Select2;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use vova07\imperavi\Widget;
/* @var $this yii\web\View */
/* @var $model common\models\Blog */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="blog-form">

    <?php $form = ActiveForm::begin(); ?>

    <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'text')->widget(Widget::className(), [
    'settings' => [
    'lang' => 'ru',
    'minHeight' => 200,
    'formatting'=> ['p', 'blockquote', 'pre', 'h1', 'h2', 'h3', 'h4', 'h5'],
    'plugins' => [
    'clips',
    'fullscreen'
      ]
     ]
    ]);
    ?>



    <?= $form->field($model, 'url')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'status_id')->dropDownList(['off','on']) ?>

    <?= $form->field($model, 'sort')->textInput() ?>

   <?= $form->field($model, 'tags')->widget(Select2::classname(), [ // собственно ошибка

    'data' => \yii\helpers\ArrayHelper::map(\common\models\Tag::find()->all(),'id','name'),
    'language' => 'ru',
    'options' => ['placeholder' => 'Выбрать таг...','multiple'=>true],
    'pluginOptions' => [
    'allowClear' => true
    ],
    ]);
    ?>


    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dragon55, 2017-07-27
@dracon55

This is because of the repository inside this extension. delete .git
Delete this folder from git git rm --cached yii2-widget-select2
Re-commit and push to server

I
Igor Vasiliev, 2017-08-19
@Isolution666

Hello.
Obviously, you transferred this file manager manually, which you can’t do, especially if you absolutely don’t understand how Yii2 works, and the framework as a whole.
In the \vendor\yiisoft\extensions.php folder
Most likely they forgot to add:

'kartik-v/yii2-krajee-base' => 
  array (
    'name' => 'kartik-v/yii2-krajee-base',
    'version' => '9999999-dev',
    'alias' => 
    array (
      '@kartik/base' => $vendorDir . '/kartik-v/yii2-krajee-base',
    ),
  ),
  'kartik-v/yii2-widget-select2' => 
  array (
    'name' => 'kartik-v/yii2-widget-select2',
    'version' => '9999999-dev',
    'alias' => 
    array (
      '@kartik/select2' => $vendorDir . '/kartik-v/yii2-widget-select2',
    ),
  ),
  'kartik-v/yii2-widget-alert' => 
  array (
    'name' => 'kartik-v/yii2-widget-alert',
    'version' => '9999999-dev',
    'alias' => 
    array (
      '@kartik/alert' => $vendorDir . '/kartik-v/yii2-widget-alert',
    ),
  ),

And there will most likely be problems with 2amigos . Check for composer entries and file folders in general, if the links are correct.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question