Commit 9933beb12aff80c3c96a7bb7156505a77154d497

Authored by Administrator
1 parent 158f1f4e

30.06.16 event images

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
... ... @@ -32,10 +32,6 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
32 32 'name',
33 33 'alias',
34 34 'body:ntext',
35   - [
36   - 'format' => 'image',
37   - 'attribute'=>'image',
38   - ],
39 35 'meta_title',
40 36 'description',
41 37 'h1',
... ...
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  
... ...