diff options
-rw-r--r-- | modules/tag/controllers/tags.php | 7 | ||||
-rw-r--r-- | modules/tag/helpers/tag.php | 7 | ||||
-rw-r--r-- | modules/tag/models/tag.php | 3 |
3 files changed, 8 insertions, 9 deletions
diff --git a/modules/tag/controllers/tags.php b/modules/tag/controllers/tags.php index 515ddd59..ad401fdb 100644 --- a/modules/tag/controllers/tags.php +++ b/modules/tag/controllers/tags.php @@ -52,7 +52,12 @@ class Tags_Controller extends REST_Controller { $form = tag::get_add_form($item); if ($form->validate()) { - tag::add($item, $form->add_tag->inputs["name"]->value); + foreach (split("[\,\ \;]", $form->add_tag->inputs["name"]->value) as $tag_name) { + $tag_name = trim($tag_name); + if ($tag_name) { + $tag = tag::add($item, $tag_name); + } + } print json_encode( array("result" => "success", diff --git a/modules/tag/helpers/tag.php b/modules/tag/helpers/tag.php index cedf307e..b8e2e233 100644 --- a/modules/tag/helpers/tag.php +++ b/modules/tag/helpers/tag.php @@ -82,20 +82,18 @@ class tag_Core { static function get_add_form($item) { $form = new Forge("tags", "", "post", array("id" => "gAddTagForm")); $group = $form->group("add_tag")->label(t("Add Tag")); - $group->input("name")->label(t("Add tag")); + $group->input("name")->label(t("Add tag"))->rules("required|length[1,64]"); $group->hidden("item_id")->value($item->id); $group->submit("")->value(t("Add Tag")); - $form->add_rules_from(ORM::factory("tag")); return $form; } static function get_rename_form($tag) { $form = new Forge("admin/tags/rename/$tag->id", "", "post", array("id" => "gRenameTagForm")); $group = $form->group("rename_tag")->label(t("Rename Tag")); - $group->input("name")->label(t("Tag name"))->value($tag->name); + $group->input("name")->label(t("Tag name"))->value($tag->name)->rules("required|length[1,64]"); $group->inputs["name"]->error_messages("in_use", t("There is already a tag with that name")); $group->submit("")->value(t("Save")); - $form->add_rules_from(ORM::factory("tag")); return $form; } @@ -104,7 +102,6 @@ class tag_Core { $group = $form->group("delete_tag") ->label(t("Really delete tag %tag_name?", array("tag_name" => $tag->name))); $group->submit("")->value(t("Delete Tag")); - $form->add_rules_from(ORM::factory("tag")); return $form; } } diff --git a/modules/tag/models/tag.php b/modules/tag/models/tag.php index 0718710d..a7355658 100644 --- a/modules/tag/models/tag.php +++ b/modules/tag/models/tag.php @@ -20,9 +20,6 @@ class Tag_Model extends ORM { protected $has_and_belongs_to_many = array("items"); - var $rules = array( - "name" => "required|length[1,64]"); - /** * Return all viewable items associated with this tag. * @param integer $limit number of rows to limit result to |