public function action_edit($id = null) { if ($supplier = Model_Supplier::find($id)) { $val = Model_Supplier::validate('edit'); if ($val->run()) { $supplier->description = Input::post('description'); $supplier->contact_person = Input::post('contact_person'); $supplier->phone = Input::post('phone'); $supplier->email = Input::post('email'); if ($supplier->save()) { Session::set_flash('success', e('Updated supplier #' . $id)); Response::redirect('admin/suppliers/view/' . $supplier->id); } else { Session::set_flash('error', e('Could not update supplier #' . $id)); } } else { if (Input::method() == 'POST') { $supplier->description = $val->validated('description'); $supplier->contact_person = $val->validated('contact_person'); $supplier->phone = $val->validated('phone'); $supplier->email = $val->validated('email'); Session::set_flash('error', $val->error()); } $this->template->set_global('supplier', $supplier, false); } $this->template->title = "Suppliers » " . $supplier->description . " » Edit"; $this->template->content = View::forge('admin/suppliers/edit'); } else { Fuel\Core\Session::set_flash('error', 'Cannot find the selected supplier'); Fuel\Core\Response::redirect_back('admin/suppliers'); } }