浏览代码

!154 修复分类管理中可将父id设置为自己的错误
Merge pull request !154 from saynone/master

Karson 6 年之前
父节点
当前提交
014c29fcd2
共有 2 个文件被更改,包括 3 次插入3 次删除
  1. 2 2
      application/admin/controller/Category.php
  2. 1 1
      application/admin/lang/zh-cn/category.php

+ 2 - 2
application/admin/controller/Category.php

@@ -102,9 +102,9 @@ class Category extends Backend
                 $params = $this->preExcludeFields($params);
 
                 if ($params['pid'] != $row['pid']) {
-                    $childrenIds = Tree::instance()->init(collection(\app\common\model\Category::select())->toArray())->getChildrenIds($row['id']);
+                    $childrenIds = Tree::instance()->init(collection(\app\common\model\Category::select())->toArray())->getChildrenIds($row['id'], true);
                     if (in_array($params['pid'], $childrenIds)) {
-                        $this->error(__('Can not change the parent to child'));
+                        $this->error(__('Can not change the parent to child or itself'));
                     }
                 }
 

+ 1 - 1
application/admin/lang/zh-cn/category.php

@@ -13,6 +13,6 @@ return [
     'Updatetime'                         => '更新时间',
     'Weigh'                              => '权重',
     'Category warmtips'                  => '温馨提示:栏目类型请前往<b>常规管理</b>-><b>系统配置</b>-><b>字典配置</b>中进行管理',
-    'Can not change the parent to child' => '父组别不能是它的子组别',
+    'Can not change the parent to child or itself' => '父组别不能是它的子组别或它自己',
     'Status'                             => '状态'
 ];