diff --git a/include/class_template.inc b/include/class_template.inc
index ab89857c9421f53c12e2e79b88d6af9f4758f7fd..cf1bb339f3043379d5b50ccb60bf1cd8c9c97548 100644
--- a/include/class_template.inc
+++ b/include/class_template.inc
@@ -1,7 +1,7 @@
 <?php
 /*
   This code is part of FusionDirectory (http://www.fusiondirectory.org/)
-  Copyright (C) 2014-2016  FusionDirectory
+  Copyright (C) 2014-2020  FusionDirectory
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -129,7 +129,7 @@ class template
     }
   }
 
-  function getNeeded ()
+  function getNeeded (): array
   {
     return $this->attributes;
   }
diff --git a/include/management/class_templateDialog.inc b/include/management/class_templateDialog.inc
index dc881e1b5a49ed3563db3a55b1f1d8cea82674c6..c6fa005005e5a2f1cf3821d157281814b13b371d 100644
--- a/include/management/class_templateDialog.inc
+++ b/include/management/class_templateDialog.inc
@@ -1,7 +1,7 @@
 <?php
 /*
   This code is part of FusionDirectory (http://www.fusiondirectory.org/)
-  Copyright (C) 2013-2019  FusionDirectory
+  Copyright (C) 2013-2020  FusionDirectory
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -56,8 +56,9 @@ class templateDialog
     }
 
     if (($this->target === NULL) &&
-        (isset($_POST[$this->post_finish]) || isset($_GET[$this->post_finish])) &&
-        is_object($this->template)) {
+        is_object($this->template) &&
+        (isset($_POST[$this->post_finish]) || isset($_GET[$this->post_finish]) || empty($this->template->getNeeded()))
+        ) {
       $this->template->save_object();
       return $this->handle_finish();
     }