diff --git a/backend/modules/goods/models/ars/Category.php b/backend/modules/goods/models/ars/Category.php index 827ec36..7831e78 100755 --- a/backend/modules/goods/models/ars/Category.php +++ b/backend/modules/goods/models/ars/Category.php @@ -102,9 +102,9 @@ class Category extends \yii\db\ActiveRecord * @return array * 数据键值对 */ - public static function modelColumn() + public static function modelColumn($model) { - return $column = self::find()->select(['name'])->where(['is_delete' => self::IS_DELETE_NO])->indexBy('id')->column(); + return $column = self::find()->select(['name'])->where(['is_delete' => self::IS_DELETE_NO])->andWhere(['!=', 'id', $model->id])->indexBy('id')->column(); } public function getIconFile() diff --git a/backend/modules/goods/views/category/_form.php b/backend/modules/goods/views/category/_form.php index 87b09b9..e6b4713 100755 --- a/backend/modules/goods/views/category/_form.php +++ b/backend/modules/goods/views/category/_form.php @@ -17,7 +17,7 @@ use backend\modules\goods\models\ars\Category; field($model, 'name')->textInput(['maxlength' => true]) ?> - field($model, 'pid')->dropDownList(array_merge([0 => '一级分类'], Category::modelColumn())) ?> + field($model, 'pid')->dropDownList(array_merge([0 => '一级分类'], Category::modelColumn($model))) ?> field($model, 'sort_order')->textInput() ?>