From 3953dde2c698d89810661435b2602fbdb55c322e Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 2 Dec 2008 21:25:15 +0000 Subject: The rearrange module will now add an album if you drag the "new album" onto the album tree. I haven't had a chance to figure out why the form does get any styling or why a textarea is no included as a list item. --- core/controllers/albums.php | 10 ++++++++++ core/helpers/album.php | 13 +++++++++++++ core/models/item.php | 2 ++ core/views/welcome.html.php | 1 + 4 files changed, 26 insertions(+) (limited to 'core') diff --git a/core/controllers/albums.php b/core/controllers/albums.php index ec5466a6..e684fa6b 100644 --- a/core/controllers/albums.php +++ b/core/controllers/albums.php @@ -46,4 +46,14 @@ class Albums_Controller extends Items_Controller { print $template; } + + /** + * @see Rest_Controller::_form_add($parameters) + */ + public function _form_add($parent_id) { + $parent = ORM::factory("item", $parent_id); + + print album::get_add_form($parent)->render(); + } + } diff --git a/core/helpers/album.php b/core/helpers/album.php index dd62d693..3e77d521 100644 --- a/core/helpers/album.php +++ b/core/helpers/album.php @@ -58,4 +58,17 @@ class album_Core { return $album; } + + static function get_add_form($parent) { + $form = new Forge("albums/{$parent->id}", "", "post", array("id" => "gAddAlbumForm")); + $group = $form->group(_("Add Album to {$parent->title}")); + $group->input("name"); + $group->input("title"); + $group->input("description"); + $group->hidden("type")->value("album"); + $group->submit(_("Create")); + $form->add_rules_from(ORM::factory("item")); + return $form; + + } } diff --git a/core/models/item.php b/core/models/item.php index 99a9c32a..9d23170f 100644 --- a/core/models/item.php +++ b/core/models/item.php @@ -21,6 +21,8 @@ class Item_Model extends ORM_MPTT { protected $children = 'items'; protected $has_one = array("owner" => "user"); + var $rules = array(); + /** * Is this item an album? * @return true if it's an album diff --git a/core/views/welcome.html.php b/core/views/welcome.html.php index 18effd55..262adcfc 100644 --- a/core/views/welcome.html.php +++ b/core/views/welcome.html.php @@ -150,6 +150,7 @@ } + -- cgit v1.2.3