Example #1
0
 public function action_create()
 {
     if (Input::method() == 'POST') {
         $val = Model_Company::validate('create');
         if ($val->run()) {
             $company = Model_Company::forge(array('company_name' => Input::post('company_name'), 'address' => Input::post('address'), 'city' => Input::post('city'), 'state' => Input::post('state'), 'pincode' => Input::post('pincode'), 'email' => Input::post('email'), 'website' => Input::post('website'), 'phone' => Input::post('phone'), 'phone1' => Input::post('phone1')));
             if ($company and $company->save()) {
                 Session::set_flash('success', 'Added company #' . $company->id . '.');
                 Response::redirect('companies');
             } else {
                 Session::set_flash('error', 'Could not save company.');
             }
         } else {
             Session::set_flash('error', $val->error());
         }
     }
     $this->template->title = "Companies";
     $this->template->content = View::forge('companies/create');
 }