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

There must be a node with id 1 #217

Closed ghost closed 5 years ago

ghost commented 5 years ago

TreeView.php

        $node = $this->displayValue ? $modelClass::findOne($this->displayValue) : null;
        $msg = null;
        if (empty($node)) {
            **$msg = Html::tag('div', $this->emptyNodeMsg, $this->emptyNodeMsgOptions);**
            $node = new $modelClass;
        }
$manageData = TreeSecurity::parseManageData([
            'formOptions' => $this->nodeFormOptions,
            'modelClass' => $modelClass,
            'formAction' => $this->nodeActions[Module::NODE_SAVE],
            'currUrl' => $url,
            'isAdmin' => $this->isAdmin,
            'iconsList' => $this->_nodeIconsList,
            'softDelete' => $this->softDelete,
            'allowNewRoots' => $this->allowNewRoots,
            'showFormButtons' => $this->showFormButtons,
            'showIDAttribute' => $this->showIDAttribute,
            'showNameAttribute' => $this->showNameAttribute,
            'nodeView' => $this->nodeView,
            'nodeAddlViews' => $this->nodeAddlViews,
            'nodeViewButtonLabels' => $this->nodeViewButtonLabels,
            'nodeSelected' => $this->_nodeSelected,
            'breadcrumbs' => $this->breadcrumbs,
            **'noNodesMessage' => $msg,**
            'nodeTitle' => $this->nodeTitle,
            'nodeTitlePlural' => $this->nodeTitlePlural,
            'defaultBtnCss' => $this->getDefaultBtnCss(),
        ]);
TreeSecurity.php
protected static function getParsedData($defaults, $data, $callback = null)
    {
        $out = [];
        $hash = '';
        foreach ($defaults as $key => $val) {
            $value = isset($data[$key]) ? $data[$key] : $val;
            **$type = 'string';**
            if (is_bool($val)) {
                $value = (bool)$value;
                $type = 'bool';
            } elseif (is_array($val)) {
                $value = empty($value) ? [] : (array)$value;
                $type = 'array';
            }
            if (is_callable($callback)) {
                $value = $callback($type, $key, $value);
            }
            $out[$key] = $value;
            **$hash .= $type === 'array' ? Json::encode($value) : $value;**
        }
        $out['treeClass'] = ArrayHelper::getValue($out, 'modelClass', Tree::class);
        /**
         * @var Module $module
         */
        $module = TreeView::module();
        return ['data' => $out, 'hash' => Yii::$app->security->hashData($hash, $module->treeEncryptSalt)];
    }

var dump at TreeSecurity.php line 143

        echo '<pre>';
        var_dump($hash);
        die;
A node with id 1 exists
string(402) "frontend\models\Categorybtn-default/index.php?r=treemanager%2Fnode%2Fsave/index.php?r=category@kvtree/views/_formw0-nodeselnodenodes111111{"id":"w0-nodeform"}{"1":"","2":"","3":"","4":"","5":""}{"submit":"","reset":""}[]"text"{"depth":"","glue":" » ","activeCss":"kv-crumb-active","untitled":"Untitled"}"

There is no node with id 1
string(502) "frontend\models\Categorybtn-default/index.php?r=treemanager%2Fnode%2Fsave/index.php?r=category@kvtree/views/_formw0-nodeselnodenodes
**No valid  are available for display. Use toolbar buttons to add .**
111111{"id":"w0-nodeform"}{"1":"","2":"","3":"","4":"","5":""}{"submit":"","reset":""}[]"text"{"depth":"","glue":" » ","activeCss":"kv-crumb-active","untitled":"Untitled"}"