summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2008-11-27 06:25:21 +0000
committerBharat Mediratta <bharat@menalto.com>2008-11-27 06:25:21 +0000
commit3992dad4861c3a1296be7e0e7d4c7a46d621c1cc (patch)
treed67dbf4933c5b87ce2da653fecf658fef9277815
parent09b27ecf9871db0bfeb7043cf8e667b66e56185a (diff)
Move form generation off into tag::get_add_form(). We can't use a controller to generate the form (it's incompatible with our REST model where controllers print stuff)
-rw-r--r--modules/tag/controllers/tags.php9
-rw-r--r--modules/tag/helpers/tag.php10
-rw-r--r--modules/tag/helpers/tag_block.php2
3 files changed, 13 insertions, 8 deletions
diff --git a/modules/tag/controllers/tags.php b/modules/tag/controllers/tags.php
index 1bf515b6..e2ab8f87 100644
--- a/modules/tag/controllers/tags.php
+++ b/modules/tag/controllers/tags.php
@@ -48,12 +48,7 @@ class Tags_Controller extends REST_Controller {
}
public function _form_add($item_id) {
- $form = new Forge(url::site("tags"), "", "post", array("id" => "gAddTag"));
- $form->input("tag_name");
- $form->hidden("item_id")->value($item_id);
- $form->submit(_("Add"));
- $form->add_rules_from(ORM::factory("tag"));
- return $form;
+ return tag::get_add_form($item_id);
}
public function _form_edit($tag) {
@@ -62,7 +57,7 @@ class Tags_Controller extends REST_Controller {
public function _create($tag) {
// @todo: check permissions
- $form = self::form_add($this->input->post('item_id'));
+ $form = tag::get_add_form($this->input->post('item_id'));
if ($form->validate()) {
$item = ORM::factory("item", $this->input->post("item_id"));
if ($item->loaded) {
diff --git a/modules/tag/helpers/tag.php b/modules/tag/helpers/tag.php
index 23edc5f2..38595b1c 100644
--- a/modules/tag/helpers/tag.php
+++ b/modules/tag/helpers/tag.php
@@ -78,4 +78,14 @@ class tag_Core {
return $cloud;
}
}
+
+ public static function get_add_form($item_id) {
+ $form = new Forge(url::site("tags"), "", "post", array("id" => "gAddTag"));
+ $group = $form->group(_("Add Tag"));
+ $group->input("tag_name");
+ $group->hidden("item_id")->value($item_id);
+ $group->submit(_("Add"));
+ $form->add_rules_from(ORM::factory("tag"));
+ return $form;
+ }
}
diff --git a/modules/tag/helpers/tag_block.php b/modules/tag/helpers/tag_block.php
index 02a536ad..2a9a25aa 100644
--- a/modules/tag/helpers/tag_block.php
+++ b/modules/tag/helpers/tag_block.php
@@ -32,7 +32,7 @@ class tag_block_Core {
if ($theme->page_type() != "tag") {
$controller = new Tags_Controller();
- $block->content->form = $controller->form_add($theme->item());
+ $block->content->form = tag::get_add_form($theme->item());
} else {
$block->content->form = "";
}