Ejemplo n.º 1
0
 public function action_edit($id = null)
 {
     is_null($id) and Response::redirect('Staff_Department');
     $staff_department = Model_Staff_Department::find($id);
     $val = Model_Staff_Department::validate('edit');
     if ($val->run()) {
         $staff_department->title = Input::post('title');
         if ($staff_department->save()) {
             Session::set_flash('success', 'Updated staff_department #' . $id);
             Response::redirect('staff/department');
         } else {
             Session::set_flash('error', 'Could not update staff_department #' . $id);
         }
     } else {
         if (Input::method() == 'POST') {
             $staff_department->title = $val->validated('title');
             Session::set_flash('error', $val->error());
         }
         $this->template->set_global('staff_department', $staff_department, false);
     }
     $this->template->title = "Staff_departments";
     $this->template->content = View::forge('staff/department/edit');
 }