Since: 1.0
Author: Kartik Visweswaran (kartikv2@gmail.com)
Inheritance: extends TreeView
Example #1
0
    public static function dropdown()
    {
        return function () {
            $input = TreeViewInput::className();
            $tree = Tree::className();
            return <<<CODE
\$form->field(\$model, 'request_param')->widget(
    {$input}::className(),
    [
        // single query fetch to render the tree
        'query'          => {$tree}::find()->addOrderBy('root, lft'),
        'headingOptions' => ['label' => 'Pages'],
        'model'          => \$model,         // input model
        'attribute'      => 'request_param', // input attribute
        'value'          => \$model->route,
        'asDropdown'     => true,           // will render the tree input widget as a dropdown.
        'multiple'       => false,          // set to false if you do not need multiple selection
        'fontAwesome'    => true,           // render font awesome icons
        'rootOptions'    => [
            'label' => '<i class="fa fa-tree"></i>',
            'class' => 'text-success',
        ],
        'options'        => [
            #'data-route' => (\$treeNode !== null) ? \$treeNode->route : null,
        ],
    ]
);
CODE;
        };
    }
Example #2
0
echo Html::a('Create Posts', ['create'], ['class' => 'btn btn-success']);
?>
            </p>
            <?php 
$userModel = new $searchModel->module->userModel();
$user_items = \yii\helpers\ArrayHelper::map($userModel::find()->where('status = 10')->all(), 'id', 'username');
?>

            <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['attribute' => 'id', 'contentOptions' => ['style' => 'width: 7%;']], ['attribute' => 'description', 'contentOptions' => ['style' => 'width: 15%;']], ['attribute' => 'category', 'value' => function ($model) {
    if ($model->category) {
        $category = Category::findOne(['id' => $model->category]);
        if ($category) {
            return $category->name;
        }
    }
}, 'contentOptions' => ['style' => 'width: 15%;'], 'filter' => TreeViewInput::widget(['model' => $searchModel, 'attribute' => 'category', 'showInactive' => true, 'query' => Category::find()->addOrderBy('root, lft'), 'headingOptions' => ['label' => 'Categories'], 'asDropdown' => true, 'multiple' => true, 'fontAwesome' => true, 'dropdownConfig' => ['dropdown' => ['style' => 'width:250px']], 'rootOptions' => ['label' => '<i class="fa fa-tree"></i>', 'class' => 'text-success']])], ['attribute' => 'user_created', 'value' => function ($model, $key, $index, $widget) {
    $userModel = new $model->module->userModel();
    return $userModel::findOne(['id' => $model->user_created])->{$model->module->userNameField};
}, 'format' => 'html', 'contentOptions' => ['style' => 'width: 10%;'], 'filter' => \yii\bootstrap\Html::activeDropDownList($searchModel, 'user_created', $user_items, ['class' => 'form-control', 'prompt' => 'Select...'])], ['attribute' => 'created_at', 'format' => ['date', 'php:d-m-Y'], 'filter' => DateControl::widget(['model' => $searchModel, 'attribute' => 'created_at', 'name' => 'kartik-date-1', 'value' => 'created_at', 'type' => DateControl::FORMAT_DATE, 'options' => ['layout' => '{picker}{input}']]), 'contentOptions' => ['style' => 'width: 12%;']], ['attribute' => 'user_last_change', 'value' => function ($model, $key, $index, $widget) {
    $userModel = new $model->module->userModel();
    return $userModel::findOne(['id' => $model->user_last_change])->{$model->module->userNameField};
}, 'format' => 'html', 'filter' => \yii\bootstrap\Html::activeDropDownList($searchModel, 'user_last_change', $user_items, ['class' => 'form-control', 'prompt' => 'Select...']), 'contentOptions' => ['style' => 'width: 10%;']], ['attribute' => 'updated_at', 'format' => ['date', 'php:d-m-Y'], 'filter' => DateControl::widget(['model' => $searchModel, 'attribute' => 'updated_at', 'name' => 'kartik-date-2', 'value' => 'updated_at', 'type' => DateControl::FORMAT_DATE, 'options' => ['layout' => '{picker}{input}']]), 'contentOptions' => ['style' => 'width: 10%;']], ['attribute' => 'publish', 'value' => function ($model, $key, $index, $widget) {
    return $model->publish == true ? '<span class="label label-success">Published</span>' : '<span class="label label-danger">Unpublished</span>';
}, 'format' => 'html', 'filter' => \yii\bootstrap\Html::activeDropDownList($searchModel, 'publish', ['0' => 'Unpublished', '1' => 'Published'], ['class' => 'form-control', 'prompt' => 'Select...']), 'contentOptions' => ['style' => 'width: 10%;']], ['class' => 'yii\\grid\\ActionColumn', 'contentOptions' => ['style' => 'min-width: 70px;']]]]);
?>

        </div>
    </div>
</div>
echo $form->field($model, 'title', ['options' => ['maxlength' => 255], 'addon' => ['prepend' => ['content' => '<i class="glyphicon glyphicon-star"></i>']]]);
?>
            <?php 
echo $form->field($model, 'description')->widget(\zxbodya\yii2\tinymce\TinyMce::className(), ['language' => 'ru', 'settings' => ['image_class_list' => [['title' => 'responsive', 'value' => 'img-responsive'], ['title' => 'none', 'value' => '']], 'rel_list' => [[title => 'FancyBox', value => 'fancybox'], [title => 'Обычная', value => '']], 'force_br_newlines' => true, 'force_p_newlines' => false, 'forced_root_block' => false, 'height' => 200, 'image_dimensions' => false, 'extended_valid_elements' => 'img[*],div[*]'], 'fileManager' => ['class' => \zxbodya\yii2\elfinder\TinyMceElFinder::className(), 'connectorRoute' => '/blog/el-finder/connector'], 'spellcheckerUrl' => 'http://speller.yandex.net/services/tinyspell']);
?>
        </div>
        <div class="col-xs-3">
            <?php 
echo $form->field($model, 'status')->dropDownList(Blog::statusOptions());
?>
            <label><?php 
echo \Yii::t('blog', 'Category');
?>
</label>
            <?php 
echo TreeViewInput::widget(['query' => Category::find()->addOrderBy('root, lft'), 'headingOptions' => ['label' => 'Категория'], 'attribute' => 'category_id', 'model' => $model, 'asDropdown' => true, 'multiple' => false, 'fontAwesome' => true, 'rootOptions' => ['label' => '<i class="fa fa-tree"></i>', 'class' => 'text-success']]);
?>
            <?php 
echo $form->field($model, 'tagged');
?>
            <div class="form-group">
                <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('blog', 'Create') : Yii::t('blog', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
            </div>
        </div>
    </div>
    <?php 
echo $form->field($model, 'body')->widget(\zxbodya\yii2\tinymce\TinyMce::className(), ['language' => 'ru', 'settings' => ['image_class_list' => [['title' => 'responsive', 'value' => 'img-responsive'], ['title' => 'none', 'value' => '']], 'rel_list' => [[title => 'FancyBox', value => 'fancybox'], [title => 'Обычная', value => '']], 'force_br_newlines' => true, 'force_p_newlines' => false, 'forced_root_block' => false, 'height' => 500, 'image_dimensions' => false, 'extended_valid_elements' => 'img[*],div[*]'], 'fileManager' => ['class' => \zxbodya\yii2\elfinder\TinyMceElFinder::className(), 'connectorRoute' => '/blog/el-finder/connector'], 'spellcheckerUrl' => 'http://speller.yandex.net/services/tinyspell']);
?>
Example #4
0
       <?php 
echo $form->field($model, 'contact_number')->textInput(['maxlength' => true]);
?>
     </div>
     <div class="col-lg-4">
       <?php 
echo $form->field($model, 'contact_person')->textInput(['maxlength' => true]);
?>
     </div>
     <div class="col-lg-4">
      <?php 
$industry = Category::find()->where(['name' => '行业'])->one();
$rootId = $industry->id;
?>
      <?php 
echo $form->field($model, 'industry')->widget(TreeViewInput::classname(), ['name' => 'Industry', 'options' => ['placeholder' => 'Select Industry...'], 'query' => Category::find()->where(['root' => $rootId])->andWhere("lvl!=0")->addOrderBy('root', 'lft'), 'rootOptions' => ['label' => '行业', 'class' => 'text-success'], 'pluginOptions' => ['name' => 'kv-product', 'asDropdown' => true, 'multiple' => false, 'fontAwesome' => false, 'rootOptions' => ['label' => '行业分类', 'class' => 'text-success']]]);
?>

     </div>
   </div> 
   <div class="row">
     <div class="col-lg-4">
       <?php 
echo $form->field($model, 'size')->textInput();
?>
     </div>
     <div class="col-lg-4">
       <?php 
echo $form->field($model, 'status')->dropdownList(ArrayHelper::map(Yii::$app->params['status'], 'id', 'name'));
?>
     </div>
Example #5
0
/* @var $model alexsers\store\models\StoreProduct */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="store-product-form">

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

    <?php 
echo $form->errorSummary($model);
?>
    <label class="control-label">Категория товара</label>
    <?php 
echo \kartik\tree\TreeViewInput::widget(['query' => StoreCategory::find()->addOrderBy('root, lft'), 'model' => $model, 'attribute' => 'category_id', 'fontAwesome' => false, 'asDropdown' => true, 'multiple' => false]);
?>

    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'description')->textarea(['rows' => 6]);
?>

    <?php 
echo $form->field($model, 'price')->textInput();
?>

    <?php 
Example #6
0
//                        'minHeight' => 200,
//                        //    'pastePlainText' => true,
//                        //  'pasteImages' => true,
//                        'plugins' => [
//                            'clips',
//                            'fullscreen'
//                        ],
////            'imageGetJson' => Url::to(['/blog/posts/get']),
////            'imageUpload' => Url::to(['/blog/posts/image-upload']),
////            'fileUpload' => Url::to(['/blog/posts/file-upload']),
////            'clipboardUploadUrl' => Url::to(['/blog/posts/clipupl'])
//                    ]
//                ]);
?>
                <?php 
echo $form->field($model, 'category')->widget(TreeViewInput::className(), ['model' => $model, 'attribute' => 'category', 'query' => Category::find()->addOrderBy('root, lft'), 'headingOptions' => ['label' => 'Categories'], 'asDropdown' => true, 'multiple' => false, 'showInactive' => true, 'fontAwesome' => true, 'rootOptions' => ['label' => '<i class="fa fa-tree"></i>', 'class' => 'text-success']]);
?>

                <?php 
echo $form->field($model, 'tags')->widget(SelectizeTextInput::className(), ['loadUrl' => ['/blog/posts/tagslist'], 'options' => ['class' => 'form-control'], 'clientOptions' => ['plugins' => ['remove_button'], 'valueField' => 'tags', 'labelField' => 'tags', 'searchField' => ['tags'], 'create' => true]]);
?>
                <div class="row-fluid">
                    <?php 
echo $form->field($model, 'attachments')->widget(UplWidget::className(), ['uploadUrl' => Url::toRoute(['/blog/posts/uploadfile']), 'previewUrl' => $model->module->ImagePathPreview, 'tempPreviewUrl' => $model->module->ImageTempPathPreview, 'KeyFolder' => $model->id]);
?>
                </div>
                <div class="row-fluid">
                    <?php 
echo $form->field($model, 'gallery')->widget(UplWidget::className(), ['uploadUrl' => Url::toRoute(['/blog/posts/uploadfile']), 'previewUrl' => $model->module->ImagePathPreview, 'tempPreviewUrl' => $model->module->ImageTempPathPreview, 'KeyFolder' => $model->id, 'galleryType' => true]);
?>
                </div>