1
0
Fork 0
mirror of https://github.com/Oreolek/kangana.git synced 2024-05-24 11:58:11 +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; $course->period = 1;
$letter->order = 1; $letter->order = 1;
$validation_course = $course->validate_create($this->request->post()); $validation_course = $course->validate_create($this->request->post());
$validation_letter = $letter->validate_create(array( $validation_letter = $letter->validate_create($this->request->post());
'subject' => $this->request->post('letter_subject'),
'text' => $this->request->post('letter_body')
));
try try
{ {
if ($validation_course->check() AND $validation_letter->check()) if ($validation_course->check() AND $validation_letter->check())
{ {
$course->create(); $course->create();
$course->add('group', (int) $this->request->post('group'));
$letter->course_id = $course->id; $letter->course_id = $course->id;
$letter->create(); $letter->create();
} }

View file

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

View file

@ -8,11 +8,15 @@ class View_Course_Simple extends View_Edit {
public $model_letter; public $model_letter;
public function controls_course() public function controls_course()
{ {
$select = Form::select('group', ORM::factory('Group')->find_all()->as_array('id', 'name'), NULL, [
'label' => I18n::translate('Group')
]);
return array( return array(
'heading' => I18n::translate('New course'), 'heading' => I18n::translate('New course'),
'controls' => array( 'controls' => array(
Form::orm_input($this->model_course, 'title'), 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> сообщение в серию сообщений.', "You <i>add</i> a message, forming a series of messages." => 'Вы <i>добавляете</i> сообщение в серию сообщений.',
"Each new subscriber gets the first message in this series." => 'Каждый новый подписчик получает первое сообщение в этой серии.', "Each new subscriber gets the first message in this series." => 'Каждый новый подписчик получает первое сообщение в этой серии.',
"You can customize the delay (1 day by default) between the messages." => 'Вы можете настроить задержку (по умолчанию - один день) между сообщениями.', "You can customize the delay (1 day by default) between the messages." => 'Вы можете настроить задержку (по умолчанию - один день) между сообщениями.',
'Group' => 'Группа',
); );