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/attributes/class_DateAttribute.inc b/include/simpleplugin/attributes/class_DateAttribute.inc
index 80cf1089e0672c3cdf9b4632f517a4729dad180c..0e50e78c8025abf554f6b463a4ae121a8db8b9b8 100644
--- a/include/simpleplugin/attributes/class_DateAttribute.inc
+++ b/include/simpleplugin/attributes/class_DateAttribute.inc
@@ -46,7 +46,7 @@ class DateAttribute extends Attribute
   {
     if ($value === "" && !$this->isRequired()) {
       return $value;
-    } elseif (is_object($this->plugin) && $this->plugin->is_template && preg_match('/%/', $value)) {
+    } elseif ($this->isTemplate() && preg_match('/%/', $value)) {
       return $value;
     } else {
       return $this->ldapToDate($value);
@@ -61,7 +61,7 @@ class DateAttribute extends Attribute
       try {
         return $this->getDateValue()->format('d.m.Y');
       } catch (Exception $e) {
-        if (is_object($this->plugin) && $this->plugin->is_template && preg_match('/%/', $this->value)) {
+        if ($this->isTemplate() && preg_match('/%/', $this->value)) {
           return $this->value;
         } else {
           return '';
@@ -103,7 +103,7 @@ class DateAttribute extends Attribute
       try {
         $this->setValue($this->getDateValue());
       } catch (Exception $e) {
-        if (is_object($this->plugin) && $this->plugin->is_template && preg_match('/%/', $this->value)) {
+        if ($this->isTemplate() && preg_match('/%/', $this->value)) {
           return $this->value;
         } else {
           throw $e;
@@ -125,7 +125,7 @@ class DateAttribute extends Attribute
         try {
           $this->getDateValue();
         } catch (Exception $e) {
-          if (is_object($this->plugin) && $this->plugin->is_template && preg_match('/%/', $this->value)) {
+          if ($this->isTemplate() && preg_match('/%/', $this->value)) {
             return;
           } else {
             return sprintf(_('Error, incorrect date: %s'), $e->getMessage());
diff --git a/include/simpleplugin/attributes/class_FileAttribute.inc b/include/simpleplugin/attributes/class_FileAttribute.inc
index 5d444d54d42c7e4592d531f5b7db693a817ee351..d647297141268e1da53899d20d59140f29bdb1ac 100644
--- a/include/simpleplugin/attributes/class_FileAttribute.inc
+++ b/include/simpleplugin/attributes/class_FileAttribute.inc
@@ -360,7 +360,7 @@ class ImageAttribute extends FileAttribute
     if ($this->isInLdap()) {
       $value = $this->computeLdapValue();
       if ($value !== '') {
-        if (isset($this->plugin) && $this->plugin->is_template) {
+        if ($this->isTemplate()) {
           /* Add %% to provide template from parsing binary string */
           $value = '%%'.$value;
         }
diff --git a/include/simpleplugin/attributes/class_IntAttribute.inc b/include/simpleplugin/attributes/class_IntAttribute.inc
index 739f7bd48005ebbf89f3c36cf4288ef6178be6b9..476f16607ac17a4ff894f8cb12c7cf89a62d3cc1 100644
--- a/include/simpleplugin/attributes/class_IntAttribute.inc
+++ b/include/simpleplugin/attributes/class_IntAttribute.inc
@@ -66,7 +66,7 @@ class IntAttribute extends Attribute
       // value is "" or array()
       return "";
     }
-    if (is_object($this->plugin) && $this->plugin->is_template) {
+    if ($this->isTemplate()) {
       return $value;
     } else {
       return intval($value);
@@ -167,7 +167,7 @@ class FloatAttribute extends IntAttribute
       // value is "" or array()
       return "";
     }
-    if (is_object($this->plugin) && $this->plugin->is_template) {
+    if ($this->isTemplate()) {
       return $value;
     } else {
       return floatval($value);
diff --git a/include/simpleplugin/class_Attribute.inc b/include/simpleplugin/class_Attribute.inc
index 51c6cbe2d88710a19468ff685cdd70d27073d78a..19dd102e23ab1779f89b1a0da7cda6ba82cf04e0 100644
--- a/include/simpleplugin/class_Attribute.inc
+++ b/include/simpleplugin/class_Attribute.inc
@@ -129,6 +129,11 @@ class Attribute
     return $this->visible;
   }
 
+  function isTemplate ()
+  {
+    return (is_object($this->plugin) && $this->plugin->is_template);
+  }
+
   function setUnique ($unique, $filter = NULL)
   {
     if ($unique === TRUE) {
@@ -572,7 +577,7 @@ class Attribute
         } else {
           $input = '{literal}'.htmlentities($value, ENT_COMPAT, 'UTF-8').'{/literal}';
         }
-      } elseif (is_object($this->plugin) && $this->plugin->is_template) {
+      } elseif ($this->isTemplate()) {
         $input = $this->renderTemplateInput();
       } else {
         $input = $this->renderFormInput();
diff --git a/include/simpleplugin/class_dialogAttributes.inc b/include/simpleplugin/class_dialogAttributes.inc
index dc7e3ca005f8dcfefe43e31f12c350e0eea01369..f6dc4940c00f47d4798b47304fcaab510c9446bf 100644
--- a/include/simpleplugin/class_dialogAttributes.inc
+++ b/include/simpleplugin/class_dialogAttributes.inc
@@ -199,8 +199,11 @@ class DialogAttribute extends SetAttribute
   {
     parent::loadPostValue();
     if ($this->isVisible()) {
-      if (isset($_POST['add'.$this->getHtmlId().'_dialog'])) {
+      $id = $this->getHtmlId();
+      if (isset($_POST['add'.$id.'_dialog'])) {
         $this->plugin->openDialog(new $this->dialogClass($this->plugin, $this));
+      } elseif (isset($_POST['add'.$id]) && isset($_POST[$id]) && $this->isTemplate()) {
+        $this->addPostValue($_POST[$id]);
       }
     }
   }
@@ -212,9 +215,22 @@ class DialogAttribute extends SetAttribute
   function renderButtons ()
   {
     $id = $this->getHtmlId();
-    $buttons  = $this->renderInputField(
+    $buttons            = '';
+    $dialogButtonValue  = '{msgPool type=addButton}';
+    if ($this->isTemplate()) {
+      $buttons  .= $this->renderInputField(
+        'text', $id,
+        array('value' => $this->editingValue)
+      );
+      $buttons  .= $this->renderInputField(
+        'submit', 'add'.$id,
+        array('value' => '{msgPool type=addButton}')
+      );
+      $dialogButtonValue = _('Add (dialog)');
+    }
+    $buttons  .= $this->renderInputField(
       'submit', 'add'.$id.'_dialog',
-      array('value' => '{msgPool type=addButton}')
+      array('value' => $dialogButtonValue)
     );
     $buttons  .= $this->renderInputField(
       'submit', 'del'.$id,
@@ -226,7 +242,12 @@ class DialogAttribute extends SetAttribute
   public function htmlIds()
   {
     $id = $this->getHtmlId();
-    return array('add'.$id.'_dialog','del'.$id,'row'.$id);
+    $ids = array('add'.$id.'_dialog','del'.$id,'row'.$id);
+    if ($this->isTemplate()) {
+      $ids[] = $id;
+      $ids[] = 'add'.$id;
+    }
+    return $ids;
   }
 }
 
@@ -322,7 +343,9 @@ class GenericDialogAttribute extends DialogAttribute
 
   function addValue ($dn, $attrs)
   {
-    if ($this->store_attr == 'dn') {
+    if ($this->isTemplate() && ($attrs === NULL)) {
+      $value = $dn;
+    } elseif ($this->store_attr == 'dn') {
       $value = $dn;
     } else {
       $value = $attrs[$this->store_attr][0];
@@ -368,7 +391,12 @@ class GenericDialogAttribute extends DialogAttribute
       $ldap->cd($config->current['BASE']);
       $ldap->search('('.$this->store_attr.'='.ldap_escape_f($value).')', $this->ldapAttributesToGet());
     }
-    $this->fillDisplayValueFrom($i, $ldap->fetch());
+    $attrs = $ldap->fetch();
+    if (empty($attrs) && $this->isTemplate()) {
+      $this->fillDisplayValueFrom($i, NULL);
+    } else {
+      $this->fillDisplayValueFrom($i, $ldap->fetch());
+    }
   }
 
   protected function ldapAttributesToGet ()
@@ -378,7 +406,9 @@ class GenericDialogAttribute extends DialogAttribute
 
   protected function fillDisplayValueFrom ($i, $attrs)
   {
-    if (!isset($attrs[$this->display_attr])) {
+    if ($this->isTemplate() && ($attrs === NULL)) {
+      $this->displays[$i] = $this->value[$i];
+    } elseif (!isset($attrs[$this->display_attr])) {
       unset($this->value[$i]);
     } else {
       if ($this->display_attr == 'dn') {
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);
     }
diff --git a/plugins/admin/groups/class_ogroup.inc b/plugins/admin/groups/class_ogroup.inc
index 1ead4c34167d77cd03ac60cb0830db0e0dfd6b55..58790aa391a293ad3f361bafbb332487d52cb828 100644
--- a/plugins/admin/groups/class_ogroup.inc
+++ b/plugins/admin/groups/class_ogroup.inc
@@ -62,8 +62,13 @@ class ObjectsAttribute extends GenericDialogAttribute
         $this->types[$i]    = 'I';
       }
     } else {
-      $this->displays[$i] = sprintf(_('Non existing dn: %s'), $this->value[$i]);
-      $this->types[$i]    = 'I';
+      if (($attrs === NULL) && $this->isTemplate()) {
+        $this->displays[$i] = $this->value[$i];
+        $this->types[$i]    = 'I';
+      } else {
+        $this->displays[$i] = sprintf(_('Non existing dn: %s'), $this->value[$i]);
+        $this->types[$i]    = 'I';
+      }
     }
   }