1
0
Fork 0
mirror of https://github.com/Oreolek/kangana.git synced 2024-05-05 02:28:17 +03:00

Courses to groups link (simple form)

This commit is contained in:
Alexander Yakovlev 2016-10-12 12:48:39 +07:00
parent b4e866d7a2
commit 34c6c8bd24
4 changed files with 9 additions and 6 deletions

View file

@ -48,15 +48,13 @@ class Controller_Course extends Controller_Layout {
$course->period = 1;
$letter->order = 1;
$validation_course = $course->validate_create($this->request->post());
$validation_letter = $letter->validate_create(array(
'subject' => $this->request->post('letter_subject'),
'text' => $this->request->post('letter_body')
));
$validation_letter = $letter->validate_create($this->request->post());
try
{
if ($validation_course->check() AND $validation_letter->check())
{
$course->create();
$course->add('group', (int) $this->request->post('group'));
$letter->course_id = $course->id;
$letter->create();
}

View file

@ -41,7 +41,7 @@ class Model_Course extends ORM {
),
'price' => array(
array('numeric')
)
),
);
}

View file

@ -8,11 +8,15 @@ class View_Course_Simple extends View_Edit {
public $model_letter;
public function controls_course()
{
$select = Form::select('group', ORM::factory('Group')->find_all()->as_array('id', 'name'), NULL, [
'label' => I18n::translate('Group')
]);
return array(
'heading' => I18n::translate('New course'),
'controls' => array(
Form::orm_input($this->model_course, 'title'),
Form::orm_textarea($this->model_course, 'description')
Form::orm_textarea($this->model_course, 'description'),
$select,
)
);
}

View file

@ -84,4 +84,5 @@ return array(
"You <i>add</i> a message, forming a series of messages." => 'Вы <i>добавляете</i> сообщение в серию сообщений.',
"Each new subscriber gets the first message in this series." => 'Каждый новый подписчик получает первое сообщение в этой серии.',
"You can customize the delay (1 day by default) between the messages." => 'Вы можете настроить задержку (по умолчанию - один день) между сообщениями.',
'Group' => 'Группа',
);