Commit fecf4bd193ba4f8be7e504cbd8f7aedfff12bf6a

Authored by Karnovsky A
1 parent 8074cc4e

-

backend/controllers/BrandController.php
@@ -98,8 +98,14 @@ class BrandController extends Controller @@ -98,8 +98,14 @@ class BrandController extends Controller
98 { 98 {
99 $model = $this->findModel($id); 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 } else { 109 } else {
104 return $this->render('update', [ 110 return $this->render('update', [
105 'model' => $model, 111 'model' => $model,
backend/views/brand/_form.php
@@ -11,6 +11,7 @@ use yii\widgets\ActiveForm; @@ -11,6 +11,7 @@ use yii\widgets\ActiveForm;
11 <div class="brand-form"> 11 <div class="brand-form">
12 12
13 <?php $form = ActiveForm::begin([ 13 <?php $form = ActiveForm::begin([
  14 + 'enableClientValidation' => false,
14 'options' => ['enctype' => 'multipart/form-data'] 15 'options' => ['enctype' => 'multipart/form-data']
15 ]); ?> 16 ]); ?>
16 17
common/modules/product/models/Brand.php
@@ -27,8 +27,6 @@ use Yii; @@ -27,8 +27,6 @@ use Yii;
27 */ 27 */
28 class Brand extends \yii\db\ActiveRecord 28 class Brand extends \yii\db\ActiveRecord
29 { 29 {
30 - public $imageUpload;  
31 -  
32 public function behaviors() 30 public function behaviors()
33 { 31 {
34 return [ 32 return [
@@ -46,12 +44,12 @@ class Brand extends \yii\db\ActiveRecord @@ -46,12 +44,12 @@ class Brand extends \yii\db\ActiveRecord
46 'translit' => true 44 'translit' => true
47 ], 45 ],
48 'uploader' => [ 46 'uploader' => [
49 - 'class' => UploadImageBehavior::className(),  
50 - 'attribute' => 'image', 47 + 'class' => UploadBehavior::className(),
  48 + 'attribute' => 'fileUpload',
51 'scenarios' => ['insert', 'update'], 49 'scenarios' => ['insert', 'update'],
52 // 'placeholder' => '@app/modules/user/assets/images/userpic.jpg', 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 // 'thumbs' => [ 53 // 'thumbs' => [
56 // 'thumb' => ['width' => 400, 'quality' => 90], 54 // 'thumb' => ['width' => 400, 'quality' => 90],
57 // 'preview' => ['width' => 200, 'height' => 200], 55 // 'preview' => ['width' => 200, 'height' => 200],
@@ -79,10 +77,9 @@ class Brand extends \yii\db\ActiveRecord @@ -79,10 +77,9 @@ class Brand extends \yii\db\ActiveRecord
79 [['brand_name_id'], 'integer'], 77 [['brand_name_id'], 'integer'],
80 [['meta_desc', 'seo_text'], 'string'], 78 [['meta_desc', 'seo_text'], 'string'],
81 [['alias', 'name'], 'string', 'max' => 250], 79 [['alias', 'name'], 'string', 'max' => 250],
82 - [['image', 'meta_title'], 'string', 'max' => 255], 80 + [['meta_title'], 'string', 'max' => 255],
83 [['meta_robots'], 'string', 'max' => 50], 81 [['meta_robots'], 'string', 'max' => 50],
84 - [['imageUpload'], 'safe'],  
85 - [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'], 82 + [['fileUpload'], 'file', 'extensions' => 'jpg, gif, png'],
86 // [['brand_name_id'], 'exist', 'skipOnError' => true, 'targetClass' => BrandName::className(), 'targetAttribute' => ['brand_name_id' => 'brand_name_id']], 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
1 -<div class="products"> 1 +<div class="special-products products<?= (!empty($class) ? ' '. $class : '')?>">
2 <h3><?= $title?></h3> 2 <h3><?= $title?></h3>
3 <ul> 3 <ul>
4 <?php foreach($products as $product) :?> 4 <?php foreach($products as $product) :?>