Browse Source

属性表单增加后台商品分类筛选

wechat_public_accounts
linyaostalker 5 years ago
parent
commit
b504393c42
  1. 1
      vendor/antgoods/goods/src/controllers/AttributeController.php
  2. 4
      vendor/antgoods/goods/src/models/ars/Attribute.php
  3. 5
      vendor/antgoods/goods/src/models/searchs/AttributeSearch.php
  4. 4
      vendor/antgoods/goods/src/views/attribute/_form.php

1
vendor/antgoods/goods/src/controllers/AttributeController.php

@ -67,6 +67,7 @@ class AttributeController extends Controller
{
$model = new Attribute();
$model->sort_order = 0;
$model->cat_id = 0;
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect('index');

4
vendor/antgoods/goods/src/models/ars/Attribute.php

@ -54,8 +54,8 @@ class Attribute extends \yii\db\ActiveRecord
{
return [
'id' => 'id',
'name' => '规格名称',
'value' => '规格内容(每项以逗号隔开)',
'name' => '属性名',
'value' => '属性值',
'type' => '类型',
'sort_order' => '排序',
'is_delete' => '是否删除,1为已删除',

5
vendor/antgoods/goods/src/models/searchs/AttributeSearch.php

@ -56,6 +56,11 @@ class AttributeSearch extends Attribute
'name',
'value',
'sort_order',
['attribute' => 'cat_id',
'value' => function ($model){
return $model->cat_id ? $model->category->name : '无限制';
},
],
[
'class' => 'iron\grid\ActionColumn',
'align' => 'center',

4
vendor/antgoods/goods/src/views/attribute/_form.php

@ -2,6 +2,8 @@
use yii\helpers\Html;
use yii\bootstrap4\ActiveForm;
use linyao\widgets\Select2;
use antgoods\goods\models\ars\Category;
/* @var $this yii\web\View */
/* @var $model antgoods\goods\models\ars\Attribute */
@ -18,6 +20,8 @@ use yii\bootstrap4\ActiveForm;
<?= $form->field($model, 'sort_order')->textInput() ?>
<?= $form->field($model, 'cat_id')->widget(Select2::className(), ["items" => array_merge([0 => '请选择'], Category::modelColumn()), "promptText" => false]) ?>
<div class="form-group">
<?= Html::submitButton('保存', ['class' => 'btn btn-success']) ?>
<?= Html::a('返回', ['index'], ['class' => 'btn btn-info']) ?>

Loading…
Cancel
Save