From 3ebb751cda5d47147a5c828b4cb32ecd4a9f8042 Mon Sep 17 00:00:00 2001 From: Jozef Selesi Date: Tue, 18 Nov 2008 08:28:32 +0000 Subject: First iteration of REST controller refactoring. RESTful controllers that refer to collections should now have plural names and there should be only one controller per resource. Updated existing classes that implement REST_Controller. The routing now works like this: GET /controller -> controller::_index() POST /controller -> controller::_create() GET /controller/id -> controller::_show() PUT /controller/id -> controller::_update() DELETE /controller/id -> controller::_delete() GET /form/edit/controller/resource_id -> controller::_form() GET /form/add/controller/data -> controller::_form() --- modules/comment/helpers/comment.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'modules/comment/helpers') diff --git a/modules/comment/helpers/comment.php b/modules/comment/helpers/comment.php index fd82d771..aaae7c17 100644 --- a/modules/comment/helpers/comment.php +++ b/modules/comment/helpers/comment.php @@ -54,12 +54,13 @@ class Comment_Core { return $comment->save(); } - static function get_add_form($item) { - $form = new Forge(url::site("comments/{$item->id}"), "", "post", array("id" => "gCommentForm")); + static function get_add_form($item_id) { + $form = new Forge(url::site("comments"), "", "post", array("id" => "gCommentForm")); $group = $form->group(_("Add Comment")); $group->input("author") ->label(_("Author")) ->id("gAuthor"); $group->input("email") ->label(_("Email")) ->id("gEmail"); $group->textarea("text")->label(_("Text")) ->id("gText"); + $group->hidden("item_id")->value($item_id); $group->submit(_("Add")); $form->add_rules_from(ORM::factory("comment")); return $form; @@ -67,7 +68,7 @@ class Comment_Core { static function get_edit_form($comment) { $form = new Forge( - url::site("comment/{$comment->id}?_method=put"), "", "post", array("id" => "gCommentForm")); + url::site("comments/{$comment->id}?_method=put"), "", "post", array("id" => "gCommentForm")); $group = $form->group(_("Edit Comment")); $group->input("author") ->label(_("Author")) ->id("gAuthor") ->value($comment->author); $group->input("email") ->label(_("Email")) ->id("gEmail") ->value($comment->email); -- cgit v1.2.3