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 // Gather possible parents for this album to be filed into
$parentChoices = [0 => '-root-']; $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) if (!empty($id_tag) && $parent['id_tag'] == $id_tag)
continue; 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) elseif (empty($_POST) && count($parentChoices) > 1)
{ {
// Choose the first non-root album as the default parent // Choose the first non-root album as the default parent
@ -146,9 +150,8 @@ class EditAlbum extends HTMLController
next($parentChoices); next($parentChoices);
$formDefaults = ['id_parent' => key($parentChoices)]; $formDefaults = ['id_parent' => key($parentChoices)];
} }
else
if (!isset($formDefaults)) $formDefaults = $_POST;
$formDefaults = isset($album) ? get_object_vars($album) : $_POST;
// Create the form, add in default values. // Create the form, add in default values.
$this->form->setData($formDefaults); $this->form->setData($formDefaults);

View File

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