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 | 97 | { |
98 | 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 | 101 | if ( ($image = UploadedFile::getInstance($model, 'image')) ) { |
102 | 102 | $model->image = $image->name; |
103 | 103 | } | ... | ... |
backend/views/event/_form.php
... | ... | @@ -11,8 +11,7 @@ use mihaildev\elfinder\ElFinder; |
11 | 11 | ?> |
12 | 12 | |
13 | 13 | <div class="event-form"> |
14 | - | |
15 | - <?php $form = ActiveForm::begin(); ?> | |
14 | + <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?> | |
16 | 15 | |
17 | 16 | <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?> |
18 | 17 | ... | ... |
backend/views/event/view.php
common/models/Event.php
... | ... | @@ -76,6 +76,7 @@ class Event extends \yii\db\ActiveRecord |
76 | 76 | [['created_at', 'updated_at' ], 'integer'], |
77 | 77 | [['name', 'alias', 'image', 'meta_title', 'description', 'h1','end_at'], 'string', 'max' => 255], |
78 | 78 | [['name','body'], 'required'], |
79 | + [['image'], 'file'], | |
79 | 80 | ]; |
80 | 81 | } |
81 | 82 | ... | ... |