diff --git a/include/class_template.inc b/include/class_template.inc
index c91d1592eed76ac7d61f5055bebbf10ae94a1c64..46037cdb05eb001e141686e80cc6c6b288bae2bb 100644
--- a/include/class_template.inc
+++ b/include/class_template.inc
@@ -171,6 +171,11 @@ class template
     }
   }
 
+  public function dialogOpened ()
+  {
+    return $this->tabObject->dialogOpened();
+  }
+
   function execute()
   {
     $smarty   = get_smarty();
@@ -181,6 +186,15 @@ class template
       if (!isset($this->attributes[$class])) {
         continue;
       }
+      if ($plugin->is_modal_dialog()) {
+        $dialogResult = $plugin->dialog->execute();
+        if ($dialogResult === FALSE) {
+          $plugin->closeDialog();
+        } else {
+          $this->tabObject->current = $class;
+          return $dialogResult;
+        }
+      }
       $attributes = array();
       foreach ($this->attributes[$class] as $attr) {
         if ($plugin->attributesAccess[$attr]->getAclInfo() !== FALSE) {
diff --git a/include/simpleplugin/class_simpleManagement.inc b/include/simpleplugin/class_simpleManagement.inc
index 8afc320cc9fba45b1d54faf7299d6dc107f3a372..9670bf57d75f44b3c81e2542ec844686d2aec454 100644
--- a/include/simpleplugin/class_simpleManagement.inc
+++ b/include/simpleplugin/class_simpleManagement.inc
@@ -92,7 +92,12 @@ class templateDialog
   {
     $smarty = get_smarty();
     if (is_object($this->template)) {
-      $smarty->assign('template_dialog', $this->template->execute());
+      $templateOutput = $this->template->execute();
+      if ($this->template->dialogOpened()) {
+        return $templateOutput;
+      } else {
+        $smarty->assign('template_dialog', $templateOutput);
+      }
     } else {
       $smarty->assign('templates', $this->templates);
     }