From a480c5ca1dbe8ccb260c70bf94536898cec6cc02 Mon Sep 17 00:00:00 2001 From: linyaostalker <602604991@qq.com> Date: Tue, 26 Nov 2019 19:59:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E8=A1=A8=E5=8D=95=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E6=97=B6=E5=A2=9E=E5=8A=A0validate()=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../goods/src/controllers/GoodsController.php | 4 +- .../antgoods/goods/src/views/goods/create.php | 26 +++--------- .../goods/src/views/goods/picture.php | 41 +++++++++++++++++++ 3 files changed, 48 insertions(+), 23 deletions(-) create mode 100644 vendor/antgoods/goods/src/views/goods/picture.php diff --git a/vendor/antgoods/goods/src/controllers/GoodsController.php b/vendor/antgoods/goods/src/controllers/GoodsController.php index eaca006..f405a98 100644 --- a/vendor/antgoods/goods/src/controllers/GoodsController.php +++ b/vendor/antgoods/goods/src/controllers/GoodsController.php @@ -82,7 +82,7 @@ class GoodsController extends Controller { $model = new Goods(); - if ($model->load(Yii::$app->request->post())) { + if ($model->load(Yii::$app->request->post()) && $model->validate()) { //商品封面图和商品详情图上传保存处理 $cover_image_id_str = $model->coverImageId; @@ -121,7 +121,7 @@ class GoodsController extends Controller $cover_image_old_id_arr = $model->image; $detail_image_old_id_arr = $model->detailImageId; - if ($model->load(Yii::$app->request->post())) { + if ($model->load(Yii::$app->request->post()) && $model->validate()) { //商品封面图和商品详情图上传保存处理 $cover_image_id_str = $model->coverImageId; diff --git a/vendor/antgoods/goods/src/views/goods/create.php b/vendor/antgoods/goods/src/views/goods/create.php index 4e98c8d..6736a1b 100644 --- a/vendor/antgoods/goods/src/views/goods/create.php +++ b/vendor/antgoods/goods/src/views/goods/create.php @@ -13,29 +13,13 @@ $this->params['breadcrumbs'][] = $this->title; Yii::$app->params['bsVersion'] = '4.x'; ?>
+
- true, - 'position' => TabsX::POS_ABOVE, - 'encodeLabels' => false, - ]); - + render('_form', [ + 'model' => $model, + ]) ?> -
- 'btn btn-success']) ?> - 'btn btn-info']) ?>
- - - - render('_form', [ -// 'model' => $model, -// ]) - ?> -
diff --git a/vendor/antgoods/goods/src/views/goods/picture.php b/vendor/antgoods/goods/src/views/goods/picture.php new file mode 100644 index 0000000..d176fc5 --- /dev/null +++ b/vendor/antgoods/goods/src/views/goods/picture.php @@ -0,0 +1,41 @@ + +field($model, 'coverImageId')->hiddenInput()->label('') ?> +field($model, 'coverImagePath')->widget(\iron\widgets\Upload::className(), [ + 'url' => 'upload', + 'deleteUrl' => 'img-id-del', + 'dragdropWidth'=> 800, + 'afterSave' => 'save-file', + 'maxCount' => 1, + 'fillInAttribute' => 'coverImageId', + 'model' => $model, + 'previewConfig' => [ + 'url' => Url::to(['image-file', 'fileidstr' => $model->coverImageId]), + ], +])->label('商品封面图') ?> + +field($model, 'detailImageId')->hiddenInput()->label('') ?> +field($model, 'detailImagePath')->widget(\iron\widgets\Upload::className(), [ + 'url' => 'upload', + 'deleteUrl' => 'img-id-del', + 'dragdropWidth'=> 800, + 'afterSave' => 'save-file', + 'maxCount' => 5, + 'fillInAttribute' => 'detailImageId', + 'model' => $model, + 'previewConfig' => [ + 'url' => Url::to(['image-file', 'fileidstr' => $model->detailImageId]), + ], +])->label('商品详情图') ?>