public function action_update(Params $param) { $this->content->bind('form', $torn); $category = Jelly::select('category')->link($param->id)->load(); if (!$category->loaded()) { throw new Error404_Exception(); } $torn = new Torn($category); if ($torn->check()) { try { $category->set($_POST); $category->save(); $this->request->redirect(Route::get('protected')->uri(array('controller' => 'category'))); } catch (Validate_Exception $e) { $torn->catch_errors($e); } } else { echo 'fail'; } }
public function action_update(Params $param) { $this->content->bind('form', $torn); $project = Jelly::select('project')->link($param->id)->load(); if (!$project->loaded()) { throw new Error404_Exception(); } $torn = new Torn($project); if ($torn->check()) { try { Transaction::begin(); $project->set($_FILES + $_POST); $project->save(); Transaction::commit(); $this->request->redirect(Route::get('protected')->uri(array('controller' => 'project'))); } catch (Validate_Exception $e) { Transaction::rollback(); $torn->catch_errors($e); } } }
public function action_update(Params $param) { $this->content->bind('form', $torn); $this->content->bind('project', $project); $image = Jelly::select('image')->with('project')->load($param->id); if (!$image->loaded()) { throw new Error404_Exception(); } $project = $image->project; $torn = new Torn($image); if ($torn->check()) { try { $image->set($_FILES + $_POST); $image->project = $project; // just in case... $image->save(); $this->request->redirect(Route::get('protected')->uri(array('controller' => 'image', 'id' => $project->link))); } catch (Validate_Exception $e) { $torn->catch_errors($e); } } }