EditAlbum: address refactor mistake

This commit is contained in:
Aaron van Geffen 2025-02-26 15:44:30 +01:00
parent 041b56ff8c
commit b775cffc0c
2 changed files with 8 additions and 5 deletions

View File

@ -67,7 +67,7 @@ class EditAlbum extends HTMLController
// Gather possible parents for this album to be filed into
$parentChoices = [0 => '-root-'];
foreach (PhotoAlbum::getHierarchy('tag', 'up') as $parent)
foreach (Tag::getOffset(0, 9999, 'tag', 'up', true) as $parent)
{
if (!empty($id_tag) && $parent['id_tag'] == $id_tag)
continue;
@ -139,6 +139,10 @@ class EditAlbum extends HTMLController
];
}
}
elseif (empty($_POST) && isset($album))
{
$formDefaults = get_object_vars($album);
}
elseif (empty($_POST) && count($parentChoices) > 1)
{
// Choose the first non-root album as the default parent
@ -146,9 +150,8 @@ class EditAlbum extends HTMLController
next($parentChoices);
$formDefaults = ['id_parent' => key($parentChoices)];
}
if (!isset($formDefaults))
$formDefaults = isset($album) ? get_object_vars($album) : $_POST;
else
$formDefaults = $_POST;
// Create the form, add in default values.
$this->form->setData($formDefaults);

View File

@ -67,7 +67,7 @@ class EditAsset extends HTMLController
// Get a list of available photo albums
$allAlbums = [];
foreach (PhotoAlbum::getHierarchy('tag', 'up') as $album)
foreach (Tag::getOffset(0, 9999, 'tag', 'up', true) as $album)
$allAlbums[$album['id_tag']] = $album['tag'];
// Figure out the current album id