From 747f6dcf770b91097402af6eb9c59fa1a4c0c2b4 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 21 Aug 2015 11:40:38 +0200 Subject: [PATCH] Form: Show the form autosubmit warning in the header tag... ...and use a unique id for the progress element. refs #8369 --- library/Icinga/Web/Form.php | 38 +++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index 40ddf4ee0..ef8168b5c 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -669,7 +669,7 @@ class Form extends Zend_Form { $this->useFormAutosubmit = (bool) $state; if ($this->useFormAutosubmit) { - $this->setAttrib('data-progress-element', 'form-header'); + $this->setAttrib('data-progress-element', 'header-' . $this->getId()); } else { $this->removeAttrib('data-progress-element'); } @@ -1206,13 +1206,16 @@ class Form extends Zend_Form 'form' => $this )); } else { - $this->addDecorator('Description', array('tag' => 'h1')); - if ($this->getUseFormAutosubmit()) { - $this->addDecorator('Autosubmit', array('accessible' => true)) - ->addDecorator('HtmlTag', array('tag' => 'div', 'class' => 'header', 'id' => 'form-header')); - } - - $this->addDecorator('FormDescriptions') + $this->addDecorator('Description', array('tag' => 'h1', 'escape' => !$this->getUseFormAutosubmit())) + ->addDecorator( + 'HtmlTag', + array( + 'tag' => 'div', + 'class' => 'header', + 'id' => 'header-' . $this->getId() + ) + ) + ->addDecorator('FormDescriptions') ->addDecorator('FormNotifications') ->addDecorator('FormErrors', array('onlyCustomFormErrors' => true)) ->addDecorator('FormElements') @@ -1256,6 +1259,25 @@ class Form extends Zend_Form return $name; } + /** + * Retrieve form description + * + * This will return the escaped description with the autosubmit warning icon if form autosubmit is enabled. + * + * @return string + */ + public function getDescription() + { + $description = parent::getDescription(); + if ($description && $this->getUseFormAutosubmit()) { + $autosubmit = $this->_getDecorator('Autosubmit', array('accessible' => true)); + $autosubmit->setElement($this); + $description = $autosubmit->render($this->getView()->escape($description)); + } + + return $description; + } + /** * Set the action to submit this form against *