diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index 0dc607412..e97190d66 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -126,6 +126,13 @@ class Form extends Zend_Form */ protected $requiredCue = '*'; + /** + * The descriptions of this form + * + * @var array + */ + protected $descriptions; + /** * Authentication manager * @@ -436,6 +443,49 @@ class Form extends Zend_Form return $this->requiredCue; } + /** + * Set the descriptions for this form + * + * @param array $descriptions + * + * @return Form + */ + public function setDescriptions(array $descriptions) + { + $this->descriptions = $descriptions; + return $this; + } + + /** + * Add a description for this form + * + * If $description is an array the second value should be + * an array as well containing additional HTML properties. + * + * @param string|array $description + * + * @return Form + */ + public function addDescription($description) + { + $this->descriptions[] = $description; + return $this; + } + + /** + * Return the descriptions of this form + * + * @return array + */ + public function getDescriptions() + { + if ($this->descriptions === null) { + return array(); + } + + return $this->descriptions; + } + /** * Create this form * @@ -860,6 +910,7 @@ class Form extends Zend_Form )); } else { $this->addDecorator('FormErrors', array('onlyCustomFormErrors' => true)) + ->addDecorator('FormDescriptions') ->addDecorator('FormElements') //->addDecorator('HtmlTag', array('tag' => 'dl', 'class' => 'zend_form')) ->addDecorator('Form'); diff --git a/library/Icinga/Web/Form/Decorator/FormDescriptions.php b/library/Icinga/Web/Form/Decorator/FormDescriptions.php new file mode 100644 index 000000000..936708e62 --- /dev/null +++ b/library/Icinga/Web/Form/Decorator/FormDescriptions.php @@ -0,0 +1,55 @@ +getElement(); + if (! $form instanceof Form) { + return $content; + } + + $view = $form->getView(); + if ($view === null) { + return $content; + } + + $descriptions = $form->getDescriptions(); + if (empty($descriptions)) { + return $content; + } + + $html = ''; + case self::PREPEND: + return $html . '' . $content; + } + } +} diff --git a/public/css/icinga/forms.less b/public/css/icinga/forms.less index ae7ebf720..d503ba037 100644 --- a/public/css/icinga/forms.less +++ b/public/css/icinga/forms.less @@ -126,10 +126,10 @@ input.link-like:hover, button.link-like:focus { .non-list-like-list { list-style-type: none; margin: 0; - padding: 0; + padding: 0.5em 0.5em 0; li { - margin: 0.5em; + padding-bottom: 0.5em; } } @@ -146,12 +146,16 @@ form div.element ul.errors { form ul.form-errors { .non-list-like-list; - display: inline-block; margin-bottom: 1em; background-color: @colorCritical; ul.errors { .non-list-like-list; + padding: 0; + + li:last-child { + padding-bottom: 0; + } } li { @@ -209,4 +213,18 @@ button.noscript-apply { html.no-js i.autosubmit-warning { .sr-only; +} + +form ul.descriptions { + .info-box; + padding: 0.5em 0.5em 0 1.8em; + + li { + padding-bottom: 0.5em; + + &:only-child { + margin-left: -1.3em; + list-style-type: none; + } + } } \ No newline at end of file diff --git a/public/css/icinga/main-content.less b/public/css/icinga/main-content.less index 74f9e1a6d..32054e242 100644 --- a/public/css/icinga/main-content.less +++ b/public/css/icinga/main-content.less @@ -206,5 +206,5 @@ table.benchmark { .info-box { padding: 0.5em; border: 1px solid lightgrey; - background-color: infobackground; + background-color: #fbfcc5; }