Skip to content

Commit 88519dd

Browse files
committed
create add form without functional part
1 parent 04d5ebb commit 88519dd

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

controllers/UserController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace app\controllers;
44

55
use yii\web\Controller;
6+
use app\models\AddForm;
67

78
class UserController extends Controller {
89

@@ -15,7 +16,9 @@ public function actionAdmin() {
1516
}
1617

1718
public function actionAdd() {
18-
return $this->render('add');
19+
20+
$model = new AddForm();
21+
return $this->render('add', compact('model'));
1922
}
2023

2124
public function actionDelete() {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use yii\base\Model;
66

7-
class PostForm extends Model {
7+
class AddForm extends Model {
88
public $title;
99
public $text;
1010
}

views/user/add.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22
use yii\helpers\Html;
3+
use yii\widgets\ActiveForm;
34
?>
45

56
<div class="wrap">
@@ -11,3 +12,9 @@
1112
</ul>
1213
</div>
1314
</div>
15+
16+
<?php $form = ActiveForm::begin() ?>
17+
<?= $form->field($model, 'title') ?>
18+
<?= $form->field($model, 'text') ?>
19+
<?= Html::submitButton('Добавить', ['class' => 'btn btn-success']) ?>
20+
<?php ActiveForm::end() ?>

0 commit comments

Comments
 (0)