Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Создание задач
  • Loading branch information
sabian committed Jan 9, 2016
1 parent f4d2019 commit 189ca50
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 1 deletion.
19 changes: 19 additions & 0 deletions controllers/TodoBackendController.php
@@ -1,4 +1,5 @@
<?php
use yupe\widgets\YFlashMessages;
use yupe\components\controllers\BackController;

/**
Expand All @@ -19,4 +20,22 @@ public function actionIndex()

$this->render('index', ['model' => $model]);
}

public function actionCreate()
{
$model = new Todo();

if ($data = Yii::app()->getRequest()->getPost('Todo')) {

$model->setAttributes($data);

if ($model->save()) {
Yii::app()->user->setFlash(YFlashMessages::SUCCESS_MESSAGE, 'Задача успешно добавлена');

$this->redirect((array)Yii::app()->getRequest()->getPost('submit-type', ['create']));
}
}

$this->render('create', ['model' => $model]);
}
}
36 changes: 36 additions & 0 deletions views/todoBackend/_form.php
@@ -0,0 +1,36 @@
<?php
/**
* @var $model Todo
* @var $form \yupe\widgets\ActiveForm
*/

$form = $this->beginWidget('\yupe\widgets\ActiveForm', [
'id' => 'todo-form',
'enableAjaxValidation' => false,
'enableClientValidation' => true,
'htmlOptions' => ['class' => 'well'],
]);
?>
<div class="alert alert-info">Поля отмеченные <span class="required">*</span> обязательны для заполнения</div>

<?= $form->errorSummary($model); ?>

<div class="row">
<div class="col-sm-12">
<?= $form->textFieldGroup($model, 'description'); ?>
</div>
</div>

<?php $this->widget('bootstrap.widgets.TbButton', [
'buttonType' => 'submit',
'context' => 'primary',
'label' => $model->isNewRecord ? 'Создать задачу и продолжить' : 'Сохранить задачу и продолжить',
]); ?>

<?php $this->widget('bootstrap.widgets.TbButton', [
'buttonType' => 'submit',
'htmlOptions' => ['name' => 'submit-type', 'value' => 'index'],
'label' => $model->isNewRecord ? 'Создать задачу и закрыть' : 'Сохранить задачу и закрыть',
]); ?>

<?php $this->endWidget(); ?>
23 changes: 23 additions & 0 deletions views/todoBackend/create.php
@@ -0,0 +1,23 @@
<?php
/**
* @var $model Todo
*/

$this->pageTitle = 'ToDo - Создание задачи';

$this->breadcrumbs = [
'Список задач' => ['/todo/todoBackend/index'],
$this->pageTitle
];

$this->menu = [
['icon' => 'fa fa-fw fa-list-alt', 'label' => 'Список задач', 'url' => ['/todo/todoBackend/index']],
['icon' => 'fa fa-fw fa-plus-square', 'label' => 'Создать задачу', 'url' => ['/todo/todoBackend/create']],
];
?>
<div class="page-header">
<h1>Задача <small>создание</small></h1>
</div>

<?= $this->renderPartial('_form', ['model' => $model]); ?>

5 changes: 4 additions & 1 deletion views/todoBackend/index.php
Expand Up @@ -8,7 +8,10 @@

$this->breadcrumbs = [ $this->pageTitle ];


$this->menu = [
['icon' => 'fa fa-fw fa-list-alt', 'label' => 'Список задач', 'url' => ['/todo/todoBackend/index']],
['icon' => 'fa fa-fw fa-plus-square', 'label' => 'Создать задачу', 'url' => ['/todo/todoBackend/create']],
];
?>
<div class="page-header">
<h1><?= $this->pageTitle ?></h1>
Expand Down

0 comments on commit 189ca50

Please sign in to comment.