kartik-v / yii2-tree-manager

An advanced tree management module using nested sets for Yii 2.
http://demos.krajee.com/tree-manager
Other
150 stars 107 forks source link

Unknown Input Appearing on the bottom #244

Closed buttflattery closed 5 years ago

buttflattery commented 5 years ago

Prerequisites

There is a strange input at the bottom that is appearing in the treeview

image

Looking into the inspector it shows the input as

<input type="text" id="w0" class="form-control hidden-xs" name="kv-node-selected" value="" data-key="1" data-krajee-treeview="treeview_60a25e70">

Steps to reproduce the issue

  1. If I am using the default options provided on the demo page even then it shows the same with the default view.

Below is the code provided

<?php

    use common\models\Campaign;
    use kartik\tree\Module;
    use kartik\tree\TreeView;
    use yii\helpers\Html;
    use yii\helpers\Url;

    /* @var $this yii\web\View */
    /* @var $searchModel common\models\CampaignSearch */
    /* @var $dataProvider yii\data\ActiveDataProvider */

    $this->title = 'Campaigns';
    $this->params['breadcrumbs'][] = $this->title;

    /*detect if user is allowed to create update the campaing */
    $appId = Yii::$app->id;
    $route = $appId . "/node/save";
?>

<div class="campaign-create">
    <div class="card">
        <div class="header">
            <h2>
                <?php echo Html::encode($this->title) ?>
                <small>Manage Campaigns</small>
            </h2>

        </div>
        <div class="body">

            <?php echo
                TreeView::widget([
                    // single query fetch to render the tree
                    // use the Campaign model you have in the previous step
                    'query' => Campaign::find()->addOrderBy('root, lft'),
                    'headingOptions' => ['label' => 'Store'],
                    'rootOptions' => ['label'=>'<span class="text-primary">Products</span>'],
                    'topRootAsHeading' => true, // this will override the headingOptions
                    'fontAwesome' => true,
                    'isAdmin' => true,
                    'iconEditSettings'=> [
                        'show' => 'list',
                        'listData' => [
                            'folder' => 'Folder',
                            'file' => 'File',
                            'mobile' => 'Phone',
                            'bell' => 'Bell',
                        ]
                    ],
                    'softDelete' => true,
                    'cacheSettings' => ['enableCache' => true]
                ]);
            ?>
        </div>
    </div>
</div>

Environment

Browsers

Operating System

Libraries

Isolating the problem

kartik-v commented 5 years ago

Can you debug your code and find out which input is being displayed on your browser console from which view?

buttflattery commented 5 years ago

@kartik-v I already added the input in the post above by copying from the console

<input type="text" id="w0" class="form-control hidden-xs" name="kv-node-selected" value="" data-key="1" data-krajee-treeview="treeview_60a25e70">

it is coming from the renderWidget() method inside the TreeView.php at the very end of the method you are concatenating the input see below, i have ruled out my custom views and just using default

public function renderWidget()
    {
        $content = strtr(
            $this->mainTemplate, [
                '{wrapper}' => $this->renderWrapper(),
                '{detail}' => $this->renderDetail(),
            ]
        );
        return strtr(
                $content, [
                    '{heading}' => $this->renderHeading(),
                    '{search}' => $this->renderSearch(),
                    '{toolbar}' => $this->renderToolbar(),
                ]
            ) . "\n" .
            Html::textInput('kv-node-selected', $this->value, $this->options) . "\n";
    }
kartik-v commented 5 years ago

Ok will create an enhancement. This is more to do with Krajee Base.