Permalink
Browse files

Создание задач

  • Loading branch information...
sabian committed Jan 9, 2016
1 parent f4d2019 commit 189ca50a797a782f087f6cc704453d9135787916
@@ -1,4 +1,5 @@
<?php
use yupe\widgets\YFlashMessages;
use yupe\components\controllers\BackController;
/**
@@ -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]);
}
}
@@ -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(); ?>
@@ -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]); ?>
@@ -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>

0 comments on commit 189ca50

Please sign in to comment.