$result = false; $Form = $API->get('Form'); $Form->require_field('albumTitle', 'Required'); $Form->set_required_fields_from_template($Template); if ($Form->submitted()) { $postvars = array('albumID', 'albumTitle', 'albumOrder'); $data = $Form->receive($postvars); $dynamic_fields = $Form->receive_from_template_fields($Template, $details); $data['albumDynamicFields'] = PerchUtil::json_safe_encode($dynamic_fields); if (is_object($Album)) { $result = $Album->update($data); } else { if (isset($data['albumID'])) { unset($data['albumID']); } $new_post = $GalleryAlbums->create($data); if ($new_post) { $result = true; PerchUtil::redirect($API->app_path() . '/edit/?id=' . $new_post->id() . '&created=1'); } else { $message = $HTML->failure_message('Sorry, that album could not be updated.'); } } if ($result) { $message = $HTML->success_message('Your album has been successfully updated. Return to %salbum listing%s', '<a href="' . $API->app_path() . '">', '</a>'); } else { $message = $HTML->failure_message('Sorry, that album could not be updated.'); } if (is_object($Album)) { $details = $Album->to_array(); } else {