Exemple #1
0
 public function action_edit($id = null)
 {
     is_null($id) and Response::redirect('request');
     if (!($request = Model_Request::find($id))) {
         Session::set_flash('error', 'Could not find request #' . $id);
         Response::redirect('request');
     }
     $val = Model_Request::validate('edit');
     if ($val->run()) {
         $request->body = Input::post('body');
         $request->ip = Input::post('ip');
         if ($request->save()) {
             Session::set_flash('success', 'Updated request #' . $id);
             Response::redirect('request');
         } else {
             Session::set_flash('error', 'Could not update request #' . $id);
         }
     } else {
         if (Input::method() == 'POST') {
             $request->body = $val->validated('body');
             $request->ip = $val->validated('ip');
             Session::set_flash('error', $val->error());
         }
         $this->template->set_global('request', $request, false);
     }
     $this->template->title = "Requests";
     $this->template->content = View::forge('request/edit');
 }