Browse Source

后台商品分类修改表单中父级下拉框取消本身数据

antshop
linyaostalker 5 years ago
parent
commit
d798786b51
  1. 4
      backend/modules/goods/models/ars/Category.php
  2. 2
      backend/modules/goods/views/category/_form.php

4
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()

2
backend/modules/goods/views/category/_form.php

@ -17,7 +17,7 @@ use backend\modules\goods\models\ars\Category;
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'pid')->dropDownList(array_merge([0 => '一级分类'], Category::modelColumn())) ?>
<?= $form->field($model, 'pid')->dropDownList(array_merge([0 => '一级分类'], Category::modelColumn($model))) ?>
<?= $form->field($model, 'sort_order')->textInput() ?>

Loading…
Cancel
Save