Commit 9933beb12aff80c3c96a7bb7156505a77154d497
1 parent
158f1f4e
30.06.16 event images
Showing
4 changed files
with
3 additions
and
7 deletions
Show diff stats
backend/controllers/EventController.php
@@ -97,7 +97,7 @@ class EventController extends Controller | @@ -97,7 +97,7 @@ class EventController extends Controller | ||
97 | { | 97 | { |
98 | $model = $this->findModel($id); | 98 | $model = $this->findModel($id); |
99 | 99 | ||
100 | - if ($model->load(Yii::$app->request->post()) && $model->save()) { | 100 | + if ($model->load(Yii::$app->request->post())) { |
101 | if ( ($image = UploadedFile::getInstance($model, 'image')) ) { | 101 | if ( ($image = UploadedFile::getInstance($model, 'image')) ) { |
102 | $model->image = $image->name; | 102 | $model->image = $image->name; |
103 | } | 103 | } |
backend/views/event/_form.php
@@ -11,8 +11,7 @@ use mihaildev\elfinder\ElFinder; | @@ -11,8 +11,7 @@ use mihaildev\elfinder\ElFinder; | ||
11 | ?> | 11 | ?> |
12 | 12 | ||
13 | <div class="event-form"> | 13 | <div class="event-form"> |
14 | - | ||
15 | - <?php $form = ActiveForm::begin(); ?> | 14 | + <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?> |
16 | 15 | ||
17 | <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?> | 16 | <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?> |
18 | 17 |
backend/views/event/view.php
@@ -32,10 +32,6 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -32,10 +32,6 @@ $this->params['breadcrumbs'][] = $this->title; | ||
32 | 'name', | 32 | 'name', |
33 | 'alias', | 33 | 'alias', |
34 | 'body:ntext', | 34 | 'body:ntext', |
35 | - [ | ||
36 | - 'format' => 'image', | ||
37 | - 'attribute'=>'image', | ||
38 | - ], | ||
39 | 'meta_title', | 35 | 'meta_title', |
40 | 'description', | 36 | 'description', |
41 | 'h1', | 37 | 'h1', |
common/models/Event.php
@@ -76,6 +76,7 @@ class Event extends \yii\db\ActiveRecord | @@ -76,6 +76,7 @@ class Event extends \yii\db\ActiveRecord | ||
76 | [['created_at', 'updated_at' ], 'integer'], | 76 | [['created_at', 'updated_at' ], 'integer'], |
77 | [['name', 'alias', 'image', 'meta_title', 'description', 'h1','end_at'], 'string', 'max' => 255], | 77 | [['name', 'alias', 'image', 'meta_title', 'description', 'h1','end_at'], 'string', 'max' => 255], |
78 | [['name','body'], 'required'], | 78 | [['name','body'], 'required'], |
79 | + [['image'], 'file'], | ||
79 | ]; | 80 | ]; |
80 | } | 81 | } |
81 | 82 |