From 13e4efa2217d380967a7de7990115025db2fa97a Mon Sep 17 00:00:00 2001
From: Johannes Meyer <johannes.meyer@netways.de>
Date: Mon, 26 Aug 2013 15:06:07 +0200
Subject: [PATCH] Make use of the helptext decorator if suitable

Refactored some uses of the form element Note so that
each one is properly attached to its input element.

refs #4566
---
 .../forms/Config/AuthenticationForm.php       |  13 +-
 library/Icinga/Web/Form.php                   |  33 ++++++
 .../forms/Command/AcknowledgeForm.php         | 111 +++++-------------
 .../application/forms/Command/CommandForm.php |  50 --------
 .../application/forms/Command/CommentForm.php |  44 ++-----
 .../forms/Command/CustomNotificationForm.php  |  67 ++++-------
 .../forms/Command/DelayNotificationForm.php   |  22 +---
 .../forms/Command/RescheduleNextCheckForm.php |  46 ++------
 .../forms/Command/ScheduleDowntimeForm.php    | 105 ++++++-----------
 .../Command/SubmitPassiveCheckResultForm.php  |  63 +++-------
 .../forms/Config/Backend/EditBackendForm.php  |  18 +--
 .../Config/Instance/EditInstanceForm.php      |  11 +-
 .../forms/Command/ConfirmationFormTest.php    |  15 ---
 13 files changed, 172 insertions(+), 426 deletions(-)

diff --git a/application/forms/Config/AuthenticationForm.php b/application/forms/Config/AuthenticationForm.php
index 2532ebba9..0480fd941 100644
--- a/application/forms/Config/AuthenticationForm.php
+++ b/application/forms/Config/AuthenticationForm.php
@@ -30,11 +30,8 @@ namespace Icinga\Form\Config;
 
 use \Zend_Config;
 use \Icinga\Application\Config as IcingaConfig;
-use \Icinga\Application\Icinga;
 use \Icinga\Application\Logger;
-use \Icinga\Application\DbAdapterFactory;
 use \Icinga\Web\Form;
-use \Icinga\Web\Form\Element\Note;
 use \Icinga\Web\Form\Decorator\ConditionalHidden;
 
 /**
@@ -280,15 +277,7 @@ class AuthenticationForm extends Form
         $order = $this->getAuthenticationOrder();
 
         foreach ($order as $name) {
-            $this->addElement(
-                new Note(
-                    array(
-                        'escape' => false,
-                        'name'  => 'title_backend_' . $name,
-                        'value' => '<h4>Backend ' . $name . '</h4>'
-                    )
-                )
-            );
+            $this->addNote('Backend ' . $name, 4);
             $this->addRemoveHint($this->filterName($name));
             $backend = $this->config->get($name, null);
             if ($backend === null) {
diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php
index 2b7bf738f..54a5816cb 100644
--- a/library/Icinga/Web/Form.php
+++ b/library/Icinga/Web/Form.php
@@ -33,6 +33,7 @@ use \Zend_View_Interface;
 use \Icinga\Exception\ProgrammingError;
 use \Icinga\Web\Form\Decorator\HelpText;
 use \Icinga\Web\Form\InvalidCSRFTokenException;
+use \Icinga\Web\Form\Element\Note;
 
 /**
  * Base class for forms providing CSRF protection, confirmation logic and auto submission
@@ -94,6 +95,15 @@ abstract class Form extends Zend_Form
      */
     private $cancelLabel;
 
+    /**
+     * Last used note-id
+     *
+     * Helper to generate unique names for note elements
+     *
+     * @var int
+     */
+    private $last_note_id = 0;
+
     /**
      * Getter for the session ID
      *
@@ -259,6 +269,29 @@ abstract class Form extends Zend_Form
         $this->addElement($submitButton);
     }
 
+    /**
+     * Add message to form
+     *
+     * @param string $message     The message to be displayed
+     * @param int    $headingType Whether it should be displayed as heading (1-6) or not (null)
+     */
+    public function addNote($message, $headingType = null)
+    {
+        $this->addElement(
+            new Note(
+                array(
+                    'escape' => $headingType === null ? false : true,
+                    'name'   => sprintf('note_%s', $this->last_note_id++),
+                    'value'  => $headingType === null ? $message : sprintf(
+                        '<h%1$s>%2$s</h%1$s>',
+                        $headingType,
+                        $message
+                    )
+                )
+            )
+        );
+    }
+
     /**
      * Enable automatic form submission on the given elements
      *
diff --git a/modules/monitoring/application/forms/Command/AcknowledgeForm.php b/modules/monitoring/application/forms/Command/AcknowledgeForm.php
index 3c55abea7..95e0a8f2e 100644
--- a/modules/monitoring/application/forms/Command/AcknowledgeForm.php
+++ b/modules/monitoring/application/forms/Command/AcknowledgeForm.php
@@ -29,7 +29,6 @@
 namespace Monitoring\Form\Command;
 
 use \Icinga\Web\Form\Element\DateTimePicker;
-use \Icinga\Web\Form\Element\Note;
 use \Icinga\Protocol\Commandpipe\Acknowledgement;
 use \Icinga\Protocol\Commandpipe\Comment;
 use \Icinga\Util\DateTimeFactory;
@@ -44,16 +43,11 @@ class AcknowledgeForm extends CommandForm
      */
     protected function create()
     {
-        $this->addElement(
-            new Note(
-                array(
-                    'name'  => 'commanddescription',
-                    'value' => t(
-                        'This command is used to acknowledge host or service problems. When a problem is '
-                        . 'acknowledged, future notifications about problems are temporarily disabled until the '
-                        . 'host/service changes from its current state.'
-                    )
-                )
+        $this->addNote(
+            t(
+                'This command is used to acknowledge host or service problems. When a problem is '
+                . 'acknowledged, future notifications about problems are temporarily disabled until the '
+                . 'host/service changes from its current state.'
             )
         );
 
@@ -65,18 +59,11 @@ class AcknowledgeForm extends CommandForm
             array(
                 'label'     => t('Comment'),
                 'rows'      => 4,
-                'required'  => true
-            )
-        );
-        $this->addElement(
-            new Note(
-                array(
-                    'name'  => 'commentnote',
-                    'value' => t(
-                        ' If you work with other administrators you may find it useful to share information '
-                        . 'about a host or service that is having problems if more than one of you may be working on '
-                        . 'it. Make sure you enter a brief description of what you are doing.'
-                    )
+                'required'  => true,
+                'helptext'  => t(
+                    ' If you work with other administrators you may find it useful to share information '
+                    . 'about a host or service that is having problems if more than one of you may be working on '
+                    . 'it. Make sure you enter a brief description of what you are doing.'
                 )
             )
         );
@@ -85,18 +72,11 @@ class AcknowledgeForm extends CommandForm
             'checkbox',
             'persistent',
             array(
-                'label' => t('Persistent Comment'),
-                'value' => false
-            )
-        );
-        $this->addElement(
-            new Note(
-                array(
-                    'name'  => 'persistentnote',
-                    'value' => t(
-                        'If you would like the comment to remain even when the acknowledgement is removed, '
-                        . 'check this option.'
-                    )
+                'label'    => t('Persistent Comment'),
+                'value'    => false,
+                'helptext' => t(
+                    'If you would like the comment to remain even when the acknowledgement is removed, '
+                    . 'check this option.'
                 )
             )
         );
@@ -105,34 +85,21 @@ class AcknowledgeForm extends CommandForm
             'checkbox',
             'expire',
             array(
-                'label' => t('Use Expire Time')
+                'label'    => t('Use Expire Time'),
+                'helptext' => t('If the acknowledgement should expire, check this option.')
             )
         );
         $this->enableAutoSubmit(array('expire'));
-        $this->addElement(
-            new Note(
-                array(
-                    'name'  => 'expirenote',
-                    'value' => t('If the acknowledgement should expire, check this option.')
-                )
-            )
-        );
+
         if ($this->getRequest()->getPost('expire', '0') === '1') {
             $now = DateTimeFactory::create();
             $this->addElement(
                 new DateTimePicker(
                     array(
-                        'name'  => 'expiretime',
-                        'label' => t('Expire Time'),
-                        'value' => $now->getTimestamp() + 3600
-                    )
-                )
-            );
-            $this->addElement(
-                new Note(
-                    array(
-                        'name'  => 'expiretimenote',
-                        'value' => t(
+                        'name'     => 'expiretime',
+                        'label'    => t('Expire Time'),
+                        'value'    => $now->getTimestamp() + 3600,
+                        'helptext' => t(
                             'Enter the expire date/time for this acknowledgement here. Icinga will '
                             . ' delete the acknowledgement after this date expired.'
                         )
@@ -145,18 +112,11 @@ class AcknowledgeForm extends CommandForm
             'checkbox',
             'sticky',
             array(
-                'label' => t('Sticky Acknowledgement'),
-                'value' => true
-            )
-        );
-        $this->addElement(
-            new Note(
-                array(
-                    'name'  => 'stickynote',
-                    'value' => t(
-                        'If you want the acknowledgement to disable notifications until the host/service '
-                        . 'recovers, check this option.'
-                    )
+                'label'    => t('Sticky Acknowledgement'),
+                'value'    => true,
+                'helptext' => t(
+                    'If you want the acknowledgement to disable notifications until the host/service '
+                    . 'recovers, check this option.'
                 )
             )
         );
@@ -165,18 +125,11 @@ class AcknowledgeForm extends CommandForm
             'checkbox',
             'notify',
             array(
-                'label' => t('Send Notification'),
-                'value' => true
-            )
-        );
-        $this->addElement(
-            new Note(
-                array(
-                    'name'  => 'sendnotificationnote',
-                    'value' => t(
-                        'If you do not want an acknowledgement notification to be sent out to the appropriate '
-                        . 'contacts, uncheck this option.'
-                    )
+                'label'    => t('Send Notification'),
+                'value'    => true,
+                'helptext' => t(
+                    'If you do not want an acknowledgement notification to be sent out to the appropriate '
+                    . 'contacts, uncheck this option.'
                 )
             )
         );
diff --git a/modules/monitoring/application/forms/Command/CommandForm.php b/modules/monitoring/application/forms/Command/CommandForm.php
index 3c6004ea3..4d09ac6f0 100644
--- a/modules/monitoring/application/forms/Command/CommandForm.php
+++ b/modules/monitoring/application/forms/Command/CommandForm.php
@@ -29,51 +29,13 @@
 namespace Monitoring\Form\Command;
 
 use Icinga\Web\Form;
-use Icinga\Web\Form\Element\Note;
 use \Zend_Form_Element_Hidden;
-use \Zend_Validate_Date;
 
 /**
  * Simple confirmation command
  */
 class CommandForm extends Form
 {
-    /**
-     * Array of messages
-     *
-     * @var string[]
-     */
-    private $notes = array();
-
-    /**
-     * Add message to stack
-     *
-     * @param string $message
-     */
-    public function addNote($message)
-    {
-        $this->notes[] = $message;
-    }
-
-    /**
-     * Purge messages from stack
-     *
-     */
-    public function clearNotes()
-    {
-        $this->notes = array();
-    }
-
-    /**
-     * Getter for notes
-     *
-     * @return string[]
-     */
-    public function getNotes()
-    {
-        return $this->notes;
-    }
-
     /**
      * Create an instance name containing hidden field
      * @return Zend_Form_Element_Hidden
@@ -93,18 +55,6 @@ class CommandForm extends Form
      */
     protected function create()
     {
-        if (count($this->getNotes())) {
-            foreach ($this->getNotes() as $nodeid => $note) {
-                $element = new Note(
-                    array(
-                        'name' => 'note_'. $nodeid,
-                        'value' => $note
-                    )
-                );
-                $this->addElement($element);
-            }
-        }
-
         $this->addElement($this->createInstanceHiddenField());
     }
 
diff --git a/modules/monitoring/application/forms/Command/CommentForm.php b/modules/monitoring/application/forms/Command/CommentForm.php
index ec9a1a7bf..28f79f444 100644
--- a/modules/monitoring/application/forms/Command/CommentForm.php
+++ b/modules/monitoring/application/forms/Command/CommentForm.php
@@ -28,7 +28,6 @@
 
 namespace Monitoring\Form\Command;
 
-use \Icinga\Web\Form\Element\Note;
 use \Icinga\Protocol\Commandpipe\Comment;
 
 /**
@@ -41,14 +40,7 @@ class CommentForm extends CommandForm
      */
     protected function create()
     {
-        $this->addElement(
-            new Note(
-                array(
-                    'name'  => 'commanddescription',
-                    'value' => t('This command is used to add a comment to hosts or services.')
-                )
-            )
-        );
+        $this->addNote(t('This command is used to add a comment to hosts or services.'));
 
         $this->addElement($this->createAuthorField());
 
@@ -58,18 +50,11 @@ class CommentForm extends CommandForm
             array(
                 'label'    => t('Comment'),
                 'rows'     => 4,
-                'required' => true
-            )
-        );
-        $this->addElement(
-            new Note(
-                array(
-                    'name'  => 'commentnote',
-                    'value' => t(
-                        'If you work with other administrators, you may find it useful to share information '
-                        . 'about a host or service that is having problems if more than one of you may be working on '
-                        . 'it. Make sure you enter a brief description of what you are doing.'
-                    )
+                'required' => true,
+                'helptext' => t(
+                    'If you work with other administrators, you may find it useful to share information '
+                    . 'about a host or service that is having problems if more than one of you may be working on '
+                    . 'it. Make sure you enter a brief description of what you are doing.'
                 )
             )
         );
@@ -78,18 +63,11 @@ class CommentForm extends CommandForm
             'checkbox',
             'persistent',
             array(
-                'label' => t('Persistent'),
-                'value' => true
-            )
-        );
-        $this->addElement(
-            new Note(
-                array(
-                    'name'  => 'persistentnote',
-                    'value' => t(
-                        'If you uncheck this option, the comment will automatically be deleted the next time '
-                        . 'Icinga is restarted.'
-                    )
+                'label'    => t('Persistent'),
+                'value'    => true,
+                'helptext' => t(
+                    'If you uncheck this option, the comment will automatically be deleted the next time '
+                    . 'Icinga is restarted.'
                 )
             )
         );
diff --git a/modules/monitoring/application/forms/Command/CustomNotificationForm.php b/modules/monitoring/application/forms/Command/CustomNotificationForm.php
index a14fad112..44166933f 100644
--- a/modules/monitoring/application/forms/Command/CustomNotificationForm.php
+++ b/modules/monitoring/application/forms/Command/CustomNotificationForm.php
@@ -28,7 +28,6 @@
 
 namespace Monitoring\Form\Command;
 
-use \Icinga\Web\Form\Element\Note;
 use \Icinga\Protocol\Commandpipe\CustomNotification;
 
 /**
@@ -41,16 +40,11 @@ class CustomNotificationForm extends CommandForm
      */
     protected function create()
     {
-        $this->addElement(
-            new Note(
-                array(
-                    'name'  => 'commanddescription',
-                    'value' => t(
-                        'This command is used to send a custom notification about hosts or services. Useful in '
-                        . 'emergencies when you need to notify admins of an issue regarding a monitored system or '
-                        . 'service.'
-                    )
-                )
+        $this->addNote(
+            t(
+                'This command is used to send a custom notification about hosts or services. Useful in '
+                . 'emergencies when you need to notify admins of an issue regarding a monitored system or '
+                . 'service.'
             )
         );
 
@@ -62,18 +56,11 @@ class CustomNotificationForm extends CommandForm
             array(
                 'label'    => t('Comment'),
                 'rows'     => 4,
-                'required' => true
-            )
-        );
-        $this->addElement(
-            new Note(
-                array(
-                    'name'  => 'commentnote',
-                    'value' => t(
-                        'If you work with other administrators, you may find it useful to share information '
-                        . 'about a host or service that is having problems if more than one of you may be working on '
-                        . 'it. Make sure you enter a brief description of what you are doing.'
-                    )
+                'required' => true,
+                'helptext' => t(
+                    'If you work with other administrators, you may find it useful to share information '
+                    . 'about a host or service that is having problems if more than one of you may be working on '
+                    . 'it. Make sure you enter a brief description of what you are doing.'
                 )
             )
         );
@@ -82,18 +69,11 @@ class CustomNotificationForm extends CommandForm
             'checkbox',
             'forced',
             array(
-                'label' => t('Forced')
-            )
-        );
-        $this->addElement(
-            new Note(
-                array(
-                    'name'  => 'forcenote',
-                    'value' => t(
-                        'Custom notifications normally follow the regular notification logic in Icinga. Selecting this '
-                        . 'option will force the notification to be sent out, regardless of time restrictions, '
-                        . 'whether or not notifications are enabled, etc.'
-                    )
+                'label'    => t('Forced'),
+                'helptext' => t(
+                    'Custom notifications normally follow the regular notification logic in Icinga. Selecting this '
+                    . 'option will force the notification to be sent out, regardless of time restrictions, '
+                    . 'whether or not notifications are enabled, etc.'
                 )
             )
         );
@@ -102,18 +82,11 @@ class CustomNotificationForm extends CommandForm
             'checkbox',
             'broadcast',
             array(
-                'label' => t('Broadcast')
-            )
-        );
-        $this->addElement(
-            new Note(
-                array(
-                    'name'  => 'broadcastnote',
-                    'value' => t(
-                        'Selecting this option causes the notification to be sent out to all normal (non-escalated) '
-                        . ' and escalated contacts. These options allow you to override the normal notification logic '
-                        . 'if you need to get an important message out.'
-                    )
+                'label'    => t('Broadcast'),
+                'helptext' => t(
+                    'Selecting this option causes the notification to be sent out to all normal (non-escalated) '
+                    . ' and escalated contacts. These options allow you to override the normal notification logic '
+                    . 'if you need to get an important message out.'
                 )
             )
         );
diff --git a/modules/monitoring/application/forms/Command/DelayNotificationForm.php b/modules/monitoring/application/forms/Command/DelayNotificationForm.php
index b44bbdcf1..acf15b445 100644
--- a/modules/monitoring/application/forms/Command/DelayNotificationForm.php
+++ b/modules/monitoring/application/forms/Command/DelayNotificationForm.php
@@ -28,8 +28,6 @@
 
 namespace Monitoring\Form\Command;
 
-use \Icinga\Web\Form\Element\Note;
-
 /**
  * Form for the delay notification command
  */
@@ -45,14 +43,8 @@ class DelayNotificationForm extends CommandForm
      */
     protected function create()
     {
-        $this->addElement(
-            new Note(
-                array(
-                    'name'  => 'commanddescription',
-                    'value' => t('This command is used to delay the next problem notification that is sent out.')
-                )
-            )
-        );
+        $this->addNote(t('This command is used to delay the next problem notification that is sent out.'));
+
         $this->addElement(
             'text',
             'minutes',
@@ -70,15 +62,13 @@ class DelayNotificationForm extends CommandForm
                             'max' => self::MAX_DELAY
                         )
                     )
+                ),
+                'helptext'      => t(
+                    'The notification delay will be disregarded if the host/service changes state before the next '
+                    . 'notification is scheduled to be sent out.'
                 )
             )
         );
-        $this->addNote(
-            t(
-                'The notification delay will be disregarded if the host/service changes state before the next '
-                . 'notification is scheduled to be sent out.'
-            )
-        );
 
         $this->setSubmitLabel(t('Delay Notification'));
 
diff --git a/modules/monitoring/application/forms/Command/RescheduleNextCheckForm.php b/modules/monitoring/application/forms/Command/RescheduleNextCheckForm.php
index 235124bc2..fd01d7e31 100644
--- a/modules/monitoring/application/forms/Command/RescheduleNextCheckForm.php
+++ b/modules/monitoring/application/forms/Command/RescheduleNextCheckForm.php
@@ -31,7 +31,6 @@ namespace Monitoring\Form\Command;
 use \Zend_Form_Element_Checkbox;
 use \Icinga\Web\Form\Element\DateTimePicker;
 use \Icinga\Util\DateTimeFactory;
-use \Icinga\Web\Form\Element\Note;
 
 /**
  * Form for scheduling checks
@@ -43,33 +42,21 @@ class RescheduleNextCheckForm extends WithChildrenCommandForm
      */
     protected function create()
     {
-        $this->addElement(
-            new Note(
-                array(
-                    'name'  => 'commanddescription',
-                    'value' => t(
-                        'This command is used to schedule the next check of hosts/services. Icinga will re-queue the '
-                        . 'check at the time you specify.'
-                    )
-                )
+        $this->addNote(
+            t(
+                'This command is used to schedule the next check of hosts/services. Icinga will re-queue the '
+                . 'check at the time you specify.'
             )
         );
 
         $this->addElement(
             new DateTimePicker(
                 array(
-                    'name'      => 'checktime',
-                    'label'     => t('Check Time'),
-                    'value'     => DateTimeFactory::create()->getTimestamp(),
-                    'required'  => !$this->getRequest()->getPost('forcecheck')
-                )
-            )
-        );
-        $this->addElement(
-            new Note(
-                array(
-                    'name'  => 'checktimenote',
-                    'value' => t('Set the date/time when this check should be executed.')
+                    'name'     => 'checktime',
+                    'label'    => t('Check Time'),
+                    'value'    => DateTimeFactory::create()->getTimestamp(),
+                    'required' => !$this->getRequest()->getPost('forcecheck'),
+                    'helptext' => t('Set the date/time when this check should be executed.')
                 )
             )
         );
@@ -77,17 +64,10 @@ class RescheduleNextCheckForm extends WithChildrenCommandForm
         $this->addElement(
             new Zend_Form_Element_Checkbox(
                 array(
-                    'name'  => 'forcecheck',
-                    'label' => t('Force Check'),
-                    'value' => true
-                )
-            )
-        );
-        $this->addElement(
-            new Note(
-                array(
-                    'name'  => 'forcechecknote',
-                    'value' => t(
+                    'name'     => 'forcecheck',
+                    'label'    => t('Force Check'),
+                    'value'    => true,
+                    'helptext' => t(
                         'If you select this option, Icinga will force a check regardless of both what time the '
                         . 'scheduled check occurs and whether or not checks are enabled.'
                     )
diff --git a/modules/monitoring/application/forms/Command/ScheduleDowntimeForm.php b/modules/monitoring/application/forms/Command/ScheduleDowntimeForm.php
index 7304ab3e2..d5772a8d9 100644
--- a/modules/monitoring/application/forms/Command/ScheduleDowntimeForm.php
+++ b/modules/monitoring/application/forms/Command/ScheduleDowntimeForm.php
@@ -35,7 +35,6 @@ use \Icinga\Web\Form\Element\DateTimePicker;
 use \Icinga\Protocol\Commandpipe\Downtime;
 use \Icinga\Protocol\Commandpipe\Comment;
 use \Icinga\Util\DateTimeFactory;
-use \Icinga\Web\Form\Element\Note;
 
 /**
  * Form for scheduling downtimes
@@ -78,17 +77,12 @@ class ScheduleDowntimeForm extends WithChildrenCommandForm
      */
     protected function create()
     {
-        $this->addElement(
-            new Note(
-                array(
-                    'name'  => 'commanddescription',
-                    'value' => t(
-                        'This command is used to schedule downtime for hosts/services. During the specified downtime, '
-                        . 'Icinga will not send notifications out about the affected objects. When the scheduled '
-                        . 'downtime expires, Icinga will send out notifications as it normally would. Scheduled '
-                        . 'downtimes are preserved across program shutdowns and restarts.'
-                    )
-                )
+        $this->addNote(
+            t(
+                'This command is used to schedule downtime for hosts/services. During the specified downtime, '
+                . 'Icinga will not send notifications out about the affected objects. When the scheduled '
+                . 'downtime expires, Icinga will send out notifications as it normally would. Scheduled '
+                . 'downtimes are preserved across program shutdowns and restarts.'
             )
         );
 
@@ -100,18 +94,11 @@ class ScheduleDowntimeForm extends WithChildrenCommandForm
             array(
                 'label'    => t('Comment'),
                 'rows'     => 4,
-                'required' => true
-            )
-        );
-        $this->addElement(
-            new Note(
-                array(
-                    'name'  => 'commentnote',
-                    'value' => t(
-                        'If you work with other administrators, you may find it useful to share information '
-                        . 'about a host or service that is having problems if more than one of you may be working on '
-                        . 'it. Make sure you enter a brief description of what you are doing.'
-                    )
+                'required' => true,
+                'helptext' => t(
+                    'If you work with other administrators, you may find it useful to share information '
+                    . 'about a host or service that is having problems if more than one of you may be working on '
+                    . 'it. Make sure you enter a brief description of what you are doing.'
                 )
             )
         );
@@ -147,34 +134,20 @@ class ScheduleDowntimeForm extends WithChildrenCommandForm
         $this->addElement(
             new DateTimePicker(
                 array(
-                    'name'  => 'starttime',
-                    'label' => t('Start Time'),
-                    'value' => $now->getTimestamp()
-                )
-            )
-        );
-        $this->addElement(
-            new Note(
-                array(
-                    'name'  => 'stattimenote',
-                    'value' => t('Set the start date/time for the downtime.')
+                    'name'     => 'starttime',
+                    'label'    => t('Start Time'),
+                    'value'    => $now->getTimestamp(),
+                    'helptext' => t('Set the start date/time for the downtime.')
                 )
             )
         );
         $this->addElement(
             new DateTimePicker(
                 array(
-                    'name'  => 'endtime',
-                    'label' => t('End Time'),
-                    'value' => $now->getTimestamp() + 3600
-                )
-            )
-        );
-        $this->addElement(
-            new Note(
-                array(
-                    'name'  => 'endtimenote',
-                    'value' => t('Set the end date/time for the downtime.')
+                    'name'     => 'endtime',
+                    'label'    => t('End Time'),
+                    'value'    => $now->getTimestamp() + 3600,
+                    'helptext' => t('Set the end date/time for the downtime.')
                 )
             )
         );
@@ -183,10 +156,10 @@ class ScheduleDowntimeForm extends WithChildrenCommandForm
             'select',
             'type',
             array(
-                'label'         => t('Downtime Type'),
-                'multiOptions'  => $this->getDowntimeTypeOptions(),
-                'required'      => true,
-                'validators'    => array(
+                'label'        => t('Downtime Type'),
+                'multiOptions' => $this->getDowntimeTypeOptions(),
+                'required'     => true,
+                'validators'   => array(
                     array(
                         'InArray',
                         true,
@@ -194,19 +167,12 @@ class ScheduleDowntimeForm extends WithChildrenCommandForm
                             array_keys($this->getDowntimeTypeOptions())
                         )
                     )
-                )
-            )
-        );
-        $this->addElement(
-            new Note(
-                array(
-                    'name'  => 'typenote',
-                    'value' => t(
-                        'If you select the fixed option, the downtime will be in effect between the start and end '
-                        . 'times you specify whereas a flexible downtime starts when the service enters a non-OK state '
-                        . '(sometime between the start and end times you specified) and lasts as long as the duration '
-                        . 'of time you enter. The duration fields do not apply for fixed downtime.'
-                    )
+                ),
+                'helptext'     => t(
+                    'If you select the fixed option, the downtime will be in effect between the start and end '
+                    . 'times you specify whereas a flexible downtime starts when the service enters a non-OK state '
+                    . '(sometime between the start and end times you specified) and lasts as long as the duration '
+                    . 'of time you enter. The duration fields do not apply for fixed downtime.'
                 )
             )
         );
@@ -242,15 +208,10 @@ class ScheduleDowntimeForm extends WithChildrenCommandForm
                 )
             );
             $this->addElements(array($hoursText, $minutesText));
-            $this->addElement(
-                new Note(
-                    array(
-                        'name'  => 'flexiblenote',
-                        'value' => t(
-                            'Enter here the duration of the downtime. Icinga will automatically delete the downtime '
-                            . 'after this time expired.'
-                        )
-                    )
+            $this->addNote(
+                t(
+                    'Enter here the duration of the downtime. Icinga will automatically delete the downtime '
+                    . 'after this time expired.'
                 )
             );
         }
diff --git a/modules/monitoring/application/forms/Command/SubmitPassiveCheckResultForm.php b/modules/monitoring/application/forms/Command/SubmitPassiveCheckResultForm.php
index 418be69ad..68f7317da 100644
--- a/modules/monitoring/application/forms/Command/SubmitPassiveCheckResultForm.php
+++ b/modules/monitoring/application/forms/Command/SubmitPassiveCheckResultForm.php
@@ -29,7 +29,6 @@
 namespace Monitoring\Form\Command;
 
 use \Icinga\Exception\ProgrammingError;
-use \Icinga\Web\Form\Element\Note;
 
 /**
  * Form for submitting passive check results
@@ -125,16 +124,11 @@ class SubmitPassiveCheckResultForm extends CommandForm
      */
     protected function create()
     {
-        $this->addElement(
-            new Note(
-                array(
-                    'name'  => 'commanddescription',
-                    'value' => t(
-                        'This command is used to submit a passive check result for particular hosts/services. It is '
-                        . 'particularly useful for resetting security-related objects to OK states once they have been '
-                        . 'dealt with.'
-                    )
-                )
+        $this->addNote(
+            t(
+                'This command is used to submit a passive check result for particular hosts/services. It is '
+                . 'particularly useful for resetting security-related objects to OK states once they have been '
+                . 'dealt with.'
             )
         );
 
@@ -142,10 +136,10 @@ class SubmitPassiveCheckResultForm extends CommandForm
             'select',
             'pluginstate',
             array(
-                'label'         => t('Check Result'),
-                'multiOptions'  => $this->getOptions(),
-                'required'      => true,
-                'validators'    => array(
+                'label'        => t('Check Result'),
+                'multiOptions' => $this->getOptions(),
+                'required'     => true,
+                'validators'   => array(
                     array(
                         'Digits',
                         true
@@ -157,15 +151,8 @@ class SubmitPassiveCheckResultForm extends CommandForm
                             array_keys($this->getOptions())
                         )
                     )
-                )
-            )
-        );
-        $this->addElement(
-            new Note(
-                array(
-                    'name'  => 'checkresultnote',
-                    'value' => t('Set the state which should be send to Icinga for this objects.')
-                )
+                ),
+                'helptext'     => t('Set the state which should be send to Icinga for this objects.')
             )
         );
 
@@ -173,17 +160,10 @@ class SubmitPassiveCheckResultForm extends CommandForm
             'textarea',
             'checkoutput',
             array(
-                'label'     => t('Check Output'),
-                'rows'      => 2,
-                'required'  => true
-            )
-        );
-        $this->addElement(
-            new Note(
-                array(
-                    'name'  => 'checkoutputnote',
-                    'value' => t('Fill in the check output string which should be send to Icinga.')
-                )
+                'label'    => t('Check Output'),
+                'rows'     => 2,
+                'required' => true,
+                'helptext' => t('Fill in the check output string which should be send to Icinga.')
             )
         );
 
@@ -191,16 +171,9 @@ class SubmitPassiveCheckResultForm extends CommandForm
             'textarea',
             'performancedata',
             array(
-                'label' => t('Performance Data'),
-                'rows' => 2
-            )
-        );
-        $this->addElement(
-            new Note(
-                array(
-                    'name'  => 'performancedatanote',
-                    'value' => t('Fill in the performance data string which should be send to Icinga.')
-                )
+                'label'    => t('Performance Data'),
+                'rows'     => 2,
+                'helptext' => t('Fill in the performance data string which should be send to Icinga.')
             )
         );
 
diff --git a/modules/monitoring/application/forms/Config/Backend/EditBackendForm.php b/modules/monitoring/application/forms/Config/Backend/EditBackendForm.php
index da7337c6e..fa66f8104 100644
--- a/modules/monitoring/application/forms/Config/Backend/EditBackendForm.php
+++ b/modules/monitoring/application/forms/Config/Backend/EditBackendForm.php
@@ -29,14 +29,9 @@
 namespace Monitoring\Form\Config\Backend;
 
 use \Zend_Config;
-
-use \Icinga\Application\Config as IcingaConfig;
-use \Icinga\Application\Icinga;
-use \Icinga\Application\Logger;
-use \Icinga\Application\DbAdapterFactory;
-
 use \Icinga\Web\Form;
-use \Icinga\Web\Form\Element\Note;
+use \Icinga\Application\Icinga;
+use \Icinga\Application\DbAdapterFactory;
 
 /**
  * Form for modifying a monitoring backend
@@ -249,14 +244,7 @@ class EditBackendForm extends Form
                 break;
             default:
                 $this->removeElement('backend_type');
-                $this->addElement(
-                    new Note(
-                        array(
-                            'name'  => 'error_note',
-                            'value' => 'Unknown Backend Type "' . $this->backend->type. '"'
-                        )
-                    )
-                );
+                $this->addNote('Unknown Backend Type "' . $this->backend->type. '"');
                 return;
         }
         $this->addDisableButton();
diff --git a/modules/monitoring/application/forms/Config/Instance/EditInstanceForm.php b/modules/monitoring/application/forms/Config/Instance/EditInstanceForm.php
index e47268e8d..f04084941 100644
--- a/modules/monitoring/application/forms/Config/Instance/EditInstanceForm.php
+++ b/modules/monitoring/application/forms/Config/Instance/EditInstanceForm.php
@@ -31,7 +31,6 @@ namespace Monitoring\Form\Config\Instance;
 
 use \Zend_Config;
 use \Icinga\Web\Form;
-use \Icinga\Web\Form\Element\Note;
 
 /**
  * Form for editing existing instances
@@ -91,14 +90,8 @@ class EditInstanceForm extends Form
      */
     private function addRemoteInstanceForm()
     {
-        $this->addElement(
-            new Note(
-                array(
-                    'name'  => 'note_ssh_info',
-                    'value' =>  'When configuring a remote host, you need to setup passwordless key authentication'
-                )
-            )
-        );
+        $this->addNote('When configuring a remote host, you need to setup passwordless key authentication');
+
         $this->addElement(
             'text',
             'instance_remote_host',
diff --git a/modules/monitoring/test/php/application/forms/Command/ConfirmationFormTest.php b/modules/monitoring/test/php/application/forms/Command/ConfirmationFormTest.php
index 53434bb0a..8d003cad0 100644
--- a/modules/monitoring/test/php/application/forms/Command/ConfirmationFormTest.php
+++ b/modules/monitoring/test/php/application/forms/Command/ConfirmationFormTest.php
@@ -8,7 +8,6 @@ require_once __DIR__. '/../../../../../application/forms/Command/CommandForm.php
 
 
 use \Zend_View;
-use \Zend_Test_PHPUnit_ControllerTestCase;
 use \Test\Icinga\Web\Form\BaseFormTest;
 
 use Monitoring\Form\Command\CommandForm;
@@ -32,18 +31,4 @@ class CommandFormTest extends BaseFormTest
         $this->assertContains('444 NOTE 1</dd>', $content);
         $this->assertContains('555 NOTE 2</dd>', $content);
     }
-
-    public function testFormNotes()
-    {
-        $form = new CommandForm();
-        $form->addNote('test1');
-        $form->addNote('test2');
-
-        $reference = array('test1', 'test2');
-        $this->assertCount(2, $form->getNotes());
-        $this->assertEquals($reference, $form->getNotes());
-
-        $form->clearNotes();
-        $this->assertCount(0, $form->getNotes());
-    }
 }