From cbf3e857c0ea662db151ce5e3547b139f2d7f2b2 Mon Sep 17 00:00:00 2001 From: jmontoya Date: Fri, 18 Mar 2016 10:24:49 +0100 Subject: [PATCH] Improve form error messages. --- .../lib/formvalidator/FormValidator.class.php | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/main/inc/lib/formvalidator/FormValidator.class.php b/main/inc/lib/formvalidator/FormValidator.class.php index b1771a7294..442c6b88f1 100755 --- a/main/inc/lib/formvalidator/FormValidator.class.php +++ b/main/inc/lib/formvalidator/FormValidator.class.php @@ -945,26 +945,17 @@ EOT; */ public function returnForm() { - $error = false; + $returnValue = ''; + /** @var HTML_QuickForm_element $element */ foreach ($this->_elements as $element) { - if (!is_null(parent::getElementError($element->getName()))) { - $error = true; + $elementError = parent::getElementError($element->getName()); + if (!is_null($elementError)) { + $returnValue .= Display::return_message($elementError, 'warning').'
'; break; } } - $returnValue = ''; - $js = null; - - if ($error) { - $returnValue = Display::return_message( - get_lang('FormHasErrorsPleaseComplete'), - 'warning' - ); - } - - $returnValue .= $js; $returnValue .= parent::toHtml(); // Add div-element which is to hold the progress bar if (isset($this->with_progress_bar) && $this->with_progress_bar) {