Beispiel #1
0
 public function action_edit($id = null)
 {
     is_null($id) and Response::redirect('Call_Center');
     $call_center = Model_Call_Center::find($id);
     $val = Model_Call_Center::validate('edit');
     if ($val->run()) {
         $call_center->title = Input::post('title');
         $call_center->address = Input::post('address');
         $call_center->shortcode = Input::post('shortcode');
         $call_center->phone_number = Input::post('phone_number');
         if ($call_center->save()) {
             Session::set_flash('success', 'Updated call_center #' . $id);
             Response::redirect('call/center');
         } else {
             Session::set_flash('error', 'Could not update call_center #' . $id);
         }
     } else {
         if (Input::method() == 'POST') {
             $call_center->title = $val->validated('title');
             $call_center->address = $val->validated('address');
             $call_center->shortcode = $val->validated('shortcode');
             $call_center->phone_number = $val->validated('phone_number');
             Session::set_flash('error', $val->error());
         }
         $this->template->set_global('call_center', $call_center, false);
     }
     $this->template->title = "Call_centers";
     $this->template->content = View::forge('call/center/edit');
 }