From 34c6c8bd24154b37aa23bf22fd9eb45b1b5af853 Mon Sep 17 00:00:00 2001 From: Alexander Yakovlev Date: Wed, 12 Oct 2016 12:48:39 +0700 Subject: [PATCH] Courses to groups link (simple form) --- application/classes/Controller/Course.php | 6 ++---- application/classes/Model/Course.php | 2 +- application/classes/View/Course/Simple.php | 6 +++++- application/i18n/ru.php | 1 + 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/application/classes/Controller/Course.php b/application/classes/Controller/Course.php index d6a7984..fecb7e9 100644 --- a/application/classes/Controller/Course.php +++ b/application/classes/Controller/Course.php @@ -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(); } diff --git a/application/classes/Model/Course.php b/application/classes/Model/Course.php index 1f7feaf..2485f38 100644 --- a/application/classes/Model/Course.php +++ b/application/classes/Model/Course.php @@ -41,7 +41,7 @@ class Model_Course extends ORM { ), 'price' => array( array('numeric') - ) + ), ); } diff --git a/application/classes/View/Course/Simple.php b/application/classes/View/Course/Simple.php index 6cbeb2d..d8da49c 100644 --- a/application/classes/View/Course/Simple.php +++ b/application/classes/View/Course/Simple.php @@ -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, ) ); } diff --git a/application/i18n/ru.php b/application/i18n/ru.php index 721e60b..911a4a8 100644 --- a/application/i18n/ru.php +++ b/application/i18n/ru.php @@ -84,4 +84,5 @@ return array( "You add a message, forming a series of messages." => 'Вы добавляете сообщение в серию сообщений.', "Each new subscriber gets the first message in this series." => 'Каждый новый подписчик получает первое сообщение в этой серии.', "You can customize the delay (1 day by default) between the messages." => 'Вы можете настроить задержку (по умолчанию - один день) между сообщениями.', + 'Group' => 'Группа', );