/** * Initializes the widget. */ public function init() { parent::init(); if (!isset($this->kcfOptions['uploadURL'])) { $this->kcfOptions['uploadURL'] = Yii::getAlias('@web') . '/upload'; } $changeChars = array_merge(Inflector::$transliteration, Yii::$app->params['changeChars']); $this->kcfOptions['filenameChangeChars'] = $changeChars; $this->kcfOptions['dirnameChangeChars'] = $changeChars; $this->kcfOptions = array_merge($this->kcfOptions, Yii::$app->params['kcfDefaultOptions']); Yii::$app->session['KCFINDER'] = $this->kcfOptions; $this->clientOptions['browseOptions'] = $this->kcfBrowseOptions; $this->clientOptions['uploadURL'] = $this->kcfOptions['uploadURL']; $this->clientOptions['multiple'] = $this->multiple; $this->clientOptions['inputName'] = $this->getInputName(); $this->clientOptions['thumbsDir'] = $this->kcfOptions['thumbsDir']; $this->clientOptions['thumbsSelector'] = '#' . $this->getThumbsId(); $this->clientOptions['thumbTemplate'] = $this->thumbTemplate; $this->buttonOptions['id'] = $this->getButtonId(); Html::addCssClass($this->options, 'form-control'); Html::addCssClass($this->buttonOptions, 'kcf btn btn-default'); }
?> </div> <div class="col-md-6"> <div class="well"> <?php echo $form->field($model, 'time')->widget(DateTimePicker::classname(), ['options' => ['placeholder' => 'Select media time ...', 'readonly' => true], 'removeButton' => false, 'convertFormat' => true, 'pluginOptions' => ['format' => 'yyyy-MM-dd HH:i:s', 'todayHighlight' => true]]); ?> <div class="row"> <div class="col-md-12"> <?php if ($module->enableUpload) { echo $form->field($model, 'file')->widget(KCFinderInputWidget::className(), ['multiple' => false, 'kcfOptions' => $kcfOptions, 'kcfBrowseOptions' => ['type' => 'files', 'lng' => substr(Yii::$app->language, 0, 2)]]); } else { echo $form->field($model, 'file')->textInput(['placeholder' => Yii::t('app', 'Url of file')]); } ?> </div> </div> <?/*= $form->field($model, 'type')->textInput() */?> </div> </div> </div> <div class="form-group"> <?php
echo $form->field($model, 'description')->textArea(['maxlength' => 155, 'placeholder' => Yii::t('app', 'This description also used as meta description')]); ?> </div> <div class="col-md-6 well"> <?php echo $form->field($model, 'parent_id')->widget(Select2::classname(), ['model' => $model, 'attribute' => 'parent_id', 'data' => $listParent, 'options' => ['placeholder' => Yii::t('app', 'Select a account parent...')], 'pluginOptions' => ['allowClear' => true], 'pluginEvents' => ["change" => 'function() { }']]); ?> <?php if ($module->enableUpload) { echo $form->field($model, 'image')->widget(KCFinderInputWidget::className(), ['multiple' => false, 'kcfOptions' => $kcfOptions, 'kcfBrowseOptions' => ['type' => 'images']]); } else { echo $form->field($model, 'image')->textInput(['placeholder' => Yii::t('app', 'Url of image')]); } ?> </div> </div> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?>
/* @var $form yii\widgets\ActiveForm */ ?> <div class="product-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'category_id')->textInput(); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php echo KCFinderInputWidget::widget(['name' => 'image']); ?> <?php ActiveForm::end(); ?> </div>
Yii::$app->session->set('KCFINDER', $kcfOptions); /* @var $this yii\web\View */ /* @var $model amilna\blog\models\Banner */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="banner-form"> <?php echo Html::beginForm(\yii\helpers\Url::toRoute(["//yes/shipping/import"]), 'post'); ?> <div class="row"> <div class='col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2'> <?php echo KCFinderInputWidget::widget(['name' => 'Shipping[csv]', 'value' => $file, 'multiple' => false, 'kcfOptions' => $kcfOptions, 'kcfBrowseOptions' => ['type' => 'files', 'lng' => substr(Yii::$app->language, 0, 2)]]); ?> </div> </div> <div class="form-group"> <?php echo Html::submitButton(Yii::t('app', 'Import'), ['class' => 'btn btn-primary']); ?> </div> <?php echo Html::endForm(); ?>
public function init() { $this->kcfOptions['disabled'] = !yii::$app->getUser()->can('upload/files'); parent::init(); }
echo $form->field($model, 'image')->widget(KCFinderInputWidget::className(), ['multiple' => false, 'kcfOptions' => $kcfOptions, 'kcfBrowseOptions' => ['type' => 'images', 'lng' => substr(Yii::$app->language, 0, 2)]]); } else { echo $form->field($model, 'image')->textInput(['placeholder' => Yii::t('app', 'Url of image')]); } ?> </div> <div id="videos" class="col-md-12" style="<?php echo $model->type == 0 ? "display:none;" : ""; ?> "> <div class="well"> <?php echo $form->field($model, 'url')->textInput(['placeholder' => Yii::t('app', 'Url of youtube or uploaded movie')]); if ($module->enableUpload) { echo KCFinderInputWidget::widget(['name' => 'videos_url', 'multiple' => false, 'kcfOptions' => $kcfOptions, 'kcfBrowseOptions' => ['type' => 'videos', 'lng' => substr(Yii::$app->language, 0, 2)]]); } ?> </div> </div> </div> <?/*= $form->field($model, 'type')->textInput() */?> </div> </div> </div> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?>
use yii\base\DynamicModel; use dosamigos\ckeditor\CKEditor; use iutbay\yii2kcfinder\KCFinderInputWidget; ?> <?php $model = new \yii\base\DynamicModel(['cms_content', 'images']); //$model->addRule(['cms_content'], 'string'); $session = Yii::$app->session; if (isset($_SESSION['KCFINDER'])) { echo "asdasd"; } print_r($session->get('KCFINDER')); $form = ActiveForm::begin(); echo $form->field($model, 'cms_content')->textarea(['class' => 'ok'])->widget(CKEditor::className(), ['options' => ['rows' => 6], 'clientOptions' => ['title' => false], 'preset' => 'standart']); echo $form->field($model, 'images')->widget(KCFinderInputWidget::className(), ['multiple' => true, 'disabled' => false]); ?> <?php ActiveForm::end(); ?> <?php // $this->registerJsFile( // Url::home().'resources/jsmodules/ckeditor.js', [ // 'depends'=>[app\assets\DashboardAsset::className(),dosamigos\ckeditor\CKEditorAsset::className()], // ] // ,\yii\web\View::POS_END); ?>