mirror of
https://github.com/Oreolek/kangana.git
synced 2024-06-16 23:11:07 +03:00
Simple course form: save entered values
This commit is contained in:
parent
2585f53054
commit
d6acc36513
|
@ -39,12 +39,11 @@ class Controller_Course extends Controller_Layout {
|
|||
$this->template = new View_Course_Simple;
|
||||
$this->template->controls = array();
|
||||
$this->template->title = __('New course');
|
||||
$course = ORM::factory('Course');
|
||||
$letter = ORM::factory('Letter');
|
||||
if ($this->request->method() === HTTP_Request::POST) {
|
||||
$course = ORM::factory('Course');
|
||||
$letter = ORM::factory('Letter');
|
||||
$course->values($this->request->post(), array('title', 'description'));
|
||||
$letter->subject = $this->request->post('letter_subject');
|
||||
$letter->text = $this->request->post('letter_body');
|
||||
$letter->values($this->request->post(), array('subject', 'text'));
|
||||
$course->price = 0;
|
||||
$course->period = 1;
|
||||
$letter->order = 1;
|
||||
|
@ -78,6 +77,8 @@ class Controller_Course extends Controller_Layout {
|
|||
$this->redirect($this->_edit_redirect($course));
|
||||
}
|
||||
}
|
||||
$this->template->model_letter = $letter;
|
||||
$this->template->model_course = $course;
|
||||
}
|
||||
|
||||
public function action_edit()
|
||||
|
|
|
@ -4,13 +4,15 @@
|
|||
* Simple course and first letter creation view controller
|
||||
**/
|
||||
class View_Course_Simple extends View_Edit {
|
||||
public $model_course;
|
||||
public $model_letter;
|
||||
public function controls_course()
|
||||
{
|
||||
return array(
|
||||
'heading' => __('New course'),
|
||||
'controls' => array(
|
||||
Form::textinput('title', '', array('label' => 'Title')),
|
||||
Form::textarea('description', '', array('label' => 'Description'))
|
||||
Form::orm_input($this->model_course, 'title'),
|
||||
Form::orm_textarea($this->model_course, 'description')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -20,8 +22,8 @@ class View_Course_Simple extends View_Edit {
|
|||
return array(
|
||||
'heading' => __('First letter'),
|
||||
'controls' => array(
|
||||
Form::textinput('letter_subject', '', array('label' => 'Subject')),
|
||||
Form::textarea('letter_body', '', array('label' => 'Message body'))
|
||||
Form::orm_input($this->model_letter, 'subject'),
|
||||
Form::orm_textarea($this->model_letter, 'text')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue