arogachev / yii2-tree

Database tree structures (Nested Sets) management for Yii 2 framework
Other
22 stars 10 forks source link

ошибка Model not found. при сохранении ноды #4

Open martrix78 opened 8 years ago

martrix78 commented 8 years ago

В общем ничего не работает кроме переименования корневого элемента :( при добавлении ноды /tree/append-to получаю ответ {"pk":null} и ошибку в консоли TypeError: c is null jstree.min.js (строка 3, столбец 16847) при изменении названия новой ноды вижу запрос _modelClass app\models\ApartmentTypes modelPk j1_2 name test _ И в ответ приходит 404 ошибка {"name":"Not Found","message":"Model not found.","code":0,"status":404,"type":"yii\web\NotFoundHttpException" }

кусок модели:

class ApartmentTypes extends \yii\db\ActiveRecord {

    public function behaviors(){
      return [
            'tree' => [
                'class' => NestedSetsBehavior::className(),
                 'treeAttribute' => 'tree',
                 'leftAttribute' => 'lft',
                 'rightAttribute' => 'rgt',
                 'depthAttribute' => 'depth',
            ],
        NestedSetsManagementBehavior::className(),
        [
              'class'              => TimestampBehavior::className(),
              'createdAtAttribute' => 'created',
              'updatedAtAttribute' => 'modified',
        ],
      ];
  }

представление:

<?php
use arogachev\tree\widgets\NestedSets;
use app\models\ApartmentTypes;
?>
<?= NestedSets::widget(['modelClass' => ApartmentTypes::className()]) ?>

Что я делаю не так? :(

arogachev commented 8 years ago

Здравствуйте. Какой первичный ключ у этой модели?

disstudio commented 7 years ago

Здравствуйте. Похожая проблема. Переименование работает. При попытке добавить дочерний элемент сразу ошибка: Uncaught TypeError: Cannot read property 'toString' of null at a.jstree.plugins.dnd.set_id (jstree.min.js:3) at HTMLDivElement. (jstree.min.js:2) at Function.each (jquery.js:365) at jQuery.fn.init.each (jquery.js:137) at jQuery.fn.init.a.fn.jstree (jstree.min.js:2) at Object.success (tree.js:65) at fire (jquery.js:3187) at Object.fireWith [as resolveWith] (jquery.js:3317) at done (jquery.js:8757) at XMLHttpRequest. (jquery.js:9123) set_id @ jstree.min.js:3 (anonymous) @ jstree.min.js:2 each @ jquery.js:365 each @ jquery.js:137 a.fn.jstree @ jstree.min.js:2 (anonymous) @ tree.js:65 fire @ jquery.js:3187 fireWith @ jquery.js:3317 done @ jquery.js:8757 (anonymous) @ jquery.js:9123

disstudio commented 7 years ago

Уже разобрался, не проходила валидация модели из-за name required.