Commit fecf4bd193ba4f8be7e504cbd8f7aedfff12bf6a
1 parent
8074cc4e
-
Showing
4 changed files
with
16 additions
and
12 deletions
Show diff stats
backend/controllers/BrandController.php
... | ... | @@ -98,8 +98,14 @@ class BrandController extends Controller |
98 | 98 | { |
99 | 99 | $model = $this->findModel($id); |
100 | 100 | |
101 | - if ($model->load(Yii::$app->request->post()) && $model->save()) { | |
102 | - return $this->redirect(['view', 'id' => $model->brand_id]); | |
101 | + if ($model->load(Yii::$app->request->post())) { | |
102 | +// var_dump($_POST); | |
103 | +// print "<hr>"; | |
104 | +// var_dump($_FILES); | |
105 | +// exit; | |
106 | + if ($model->save()) { | |
107 | + return $this->redirect(['view', 'id' => $model->brand_id]); | |
108 | + } | |
103 | 109 | } else { |
104 | 110 | return $this->render('update', [ |
105 | 111 | 'model' => $model, | ... | ... |
backend/views/brand/_form.php
common/modules/product/models/Brand.php
... | ... | @@ -27,8 +27,6 @@ use Yii; |
27 | 27 | */ |
28 | 28 | class Brand extends \yii\db\ActiveRecord |
29 | 29 | { |
30 | - public $imageUpload; | |
31 | - | |
32 | 30 | public function behaviors() |
33 | 31 | { |
34 | 32 | return [ |
... | ... | @@ -46,12 +44,12 @@ class Brand extends \yii\db\ActiveRecord |
46 | 44 | 'translit' => true |
47 | 45 | ], |
48 | 46 | 'uploader' => [ |
49 | - 'class' => UploadImageBehavior::className(), | |
50 | - 'attribute' => 'image', | |
47 | + 'class' => UploadBehavior::className(), | |
48 | + 'attribute' => 'fileUpload', | |
51 | 49 | 'scenarios' => ['insert', 'update'], |
52 | 50 | // 'placeholder' => '@app/modules/user/assets/images/userpic.jpg', |
53 | - 'path' => '@storage/{alias}', | |
54 | - 'url' => '/storage/{alias}', | |
51 | + 'path' => '@storage/brands/{alias}', | |
52 | + 'url' => '/storage/brands/{alias}', | |
55 | 53 | // 'thumbs' => [ |
56 | 54 | // 'thumb' => ['width' => 400, 'quality' => 90], |
57 | 55 | // 'preview' => ['width' => 200, 'height' => 200], |
... | ... | @@ -79,10 +77,9 @@ class Brand extends \yii\db\ActiveRecord |
79 | 77 | [['brand_name_id'], 'integer'], |
80 | 78 | [['meta_desc', 'seo_text'], 'string'], |
81 | 79 | [['alias', 'name'], 'string', 'max' => 250], |
82 | - [['image', 'meta_title'], 'string', 'max' => 255], | |
80 | + [['meta_title'], 'string', 'max' => 255], | |
83 | 81 | [['meta_robots'], 'string', 'max' => 50], |
84 | - [['imageUpload'], 'safe'], | |
85 | - [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'], | |
82 | + [['fileUpload'], 'file', 'extensions' => 'jpg, gif, png'], | |
86 | 83 | // [['brand_name_id'], 'exist', 'skipOnError' => true, 'targetClass' => BrandName::className(), 'targetAttribute' => ['brand_name_id' => 'brand_name_id']], |
87 | 84 | ]; |
88 | 85 | } | ... | ... |
common/modules/product/widgets/views/products_block.php