diff --git a/models/BrandSize.php b/models/BrandSize.php
index bf70bf6..a87854a 100644
--- a/models/BrandSize.php
+++ b/models/BrandSize.php
@@ -2,6 +2,7 @@
namespace artweb\artbox\ecommerce\models;
+use artweb\artbox\behaviors\SaveImgBehavior;
use Yii;
/**
@@ -12,11 +13,25 @@ use Yii;
* @property string $image
*
* @property Brand $brand
- * @property BrandSizeToCategory[] $brandSizeToCategories
* @property Category[] $categories
*/
class BrandSize extends \yii\db\ActiveRecord
{
+ public function behaviors()
+ {
+ return [
+ 'image' => [
+ 'class' => SaveImgBehavior::className(),
+ 'fields' => [
+ [
+ 'name' => 'image',
+ 'directory' => 'products',
+ ],
+ ],
+ ],
+ ];
+ }
+
/**
* @inheritdoc
*/
@@ -60,14 +75,6 @@ class BrandSize extends \yii\db\ActiveRecord
/**
* @return \yii\db\ActiveQuery
*/
- public function getBrandSizeToCategories()
- {
- return $this->hasMany(BrandSizeToCategory::className(), ['brand_size_id' => 'id']);
- }
-
- /**
- * @return \yii\db\ActiveQuery
- */
public function getCategories()
{
return $this->hasMany(Category::className(), ['id' => 'category_id'])->viaTable('brand_size_to_category', ['brand_size_id' => 'id']);
diff --git a/views/brand-size/_form.php b/views/brand-size/_form.php
index 027b8d8..bfd4549 100644
--- a/views/brand-size/_form.php
+++ b/views/brand-size/_form.php
@@ -1,25 +1,72 @@
-
+
+
+ = $form->field($model, 'brand_id')
+ ->textInput() ?>
+
+ = $form->field($model, 'image')
+ ->widget(
+ \kartik\file\FileInput::className(),
+ [
+ 'language' => 'ru',
+ 'options' => [
+ 'accept' => 'image/*',
+ 'multiple' => false,
+ 'deleteurl' => $model->isNewRecord ? false : Url::to(
+ [
+ '/ecommerce/manage/delete-size',
+ 'id' => $model->id,
+ ]
+ ),
+ 'class' => $model->isNewRecord ? '' : 'artbox-delete-file',
+ ],
+ 'pluginOptions' => [
+ 'allowedFileExtensions' => [
+ 'jpg',
+ 'gif',
+ 'png',
+ ],
+ 'initialPreview' => !empty(
+ $model->getBehavior('image')
+ ->getImageUrl(0, false)
+ ) ? ArtboxImageHelper::getImage(
+ $model->getBehavior('image')->imageUrl,
+ 'list'
+ ) : '',
+ 'initialPreviewShowDelete' => false,
+ 'overwriteInitial' => true,
+ 'showRemove' => true,
+ 'showUpload' => false,
+ 'showClose' => false,
+ 'previewFileType' => 'image',
+ ],
+ ]
+ ); ?>
- = $form->field($model, 'brand_id')->textInput() ?>
-
- = $form->field($model, 'image')->textInput(['maxlength' => true]) ?>
-
-
- = Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
-
-
+
+ = Html::submitButton(
+ $model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'),
+ [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]
+ ) ?>
+
+
--
libgit2 0.21.4