From 0a5d7edfadd20bcbbc2d4f5dec9fda67de622789 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Thu, 6 Aug 2015 11:50:05 +0000 Subject: [PATCH] form : display the help with the error if both are defined git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2212 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- form.php | 86 +++++++++++++++++++++----------------------------------- 1 file changed, 32 insertions(+), 54 deletions(-) diff --git a/form.php b/form.php index 52d8bcd..03666c5 100644 --- a/form.php +++ b/form.php @@ -272,6 +272,8 @@ class formfield $res .= "
\n"; if (is_string ($this->defaults)) $this->defaults = array ($this->defaults); + if (count ($this->titles) === 0) + $this->titles = array (""); foreach ($this->titles as $key=>$val) { $res .= "
"; @@ -305,17 +307,13 @@ class formfield $res .= "
\n"; } - if (isset ($this->errors)) + if (isset ($this->errors) || isset ($this->help)) { $res .= " ". - $this->errors[1]."\n"; - } - elseif (isset ($this->help)) - { - $res .= " ".$this->help. - "\n"; + $res .= htmlspecialchars ($this->name, ENT_QUOTES)."_help'>"; + if (isset ($this->help)) $res .= $this->help."
\n"; + if (isset ($this->errors)) $res .= $this->errors[1]; + $res .= "\n"; } $res .= "
\n"; // End controls $res .= " \n"; // End form-group @@ -387,17 +385,13 @@ class formfield $res .= htmlspecialchars ($this->name, ENT_QUOTES)."_help'"; } $res .= "/>\n"; - if (isset ($this->errors)) + if (isset ($this->errors) || isset ($this->help)) { $res .= " ". - $this->errors[1]."\n"; - } - elseif (isset ($this->help)) - { - $res .= " ".$this->help. - "\n"; + $res .= htmlspecialchars ($this->name, ENT_QUOTES)."_help'>"; + if (isset ($this->help)) $res .= $this->help."
\n"; + if (isset ($this->errors)) $res .= $this->errors[1]; + $res .= "\n"; } $res .= " \n"; // End controls $res .= " \n"; // End form-group @@ -464,17 +458,13 @@ class formfield $res .= ""; } - if (isset ($this->errors)) + if (isset ($this->errors) || isset ($this->help)) { $res .= " ". - $this->errors[1]."\n"; - } - elseif (isset ($this->help)) - { - $res .= " ".$this->help. - "\n"; + $res .= htmlspecialchars ($this->name, ENT_QUOTES)."_help'>"; + if (isset ($this->help)) $res .= $this->help."
\n"; + if (isset ($this->errors)) $res .= $this->errors[1]; + $res .= "\n"; } $res .= " \n"; // End controls $res .= " \n"; // End form-group @@ -568,17 +558,13 @@ class formfield } $res .= " \n"; - if (isset ($this->errors)) + if (isset ($this->errors) || isset ($this->help)) { $res .= " ". - $this->errors[1]."\n"; - } - elseif (isset ($this->help)) - { - $res .= " ".$this->help - ."\n"; + $res .= htmlspecialchars ($this->name, ENT_QUOTES)."_help'>"; + if (isset ($this->help)) $res .= $this->help."
\n"; + if (isset ($this->errors)) $res .= $this->errors[1]; + $res .= "\n"; } } else @@ -669,17 +655,13 @@ class formfield else $res .= htmlspecialchars ($this->defaults, ENT_QUOTES); $res .= "\n"; - if (isset ($this->errors)) + if (isset ($this->errors) || isset ($this->help)) { $res .= " ". - $this->errors[1]."\n"; - } - elseif (isset ($this->help)) - { - $res .= " ".$this->help - ."\n"; + $res .= htmlspecialchars ($this->name, ENT_QUOTES)."_help'>"; + if (isset ($this->help)) $res .= $this->help."
\n"; + if (isset ($this->errors)) $res .= $this->errors[1]; + $res .= "\n"; } $res .= " \n"; // End controls $res .= " \n"; // End form-group @@ -732,17 +714,13 @@ class formfield $res .= htmlspecialchars ($this->name, ENT_QUOTES)."_help'"; } $res .= "/>\n"; - if (isset ($this->errors)) + if (isset ($this->errors) || isset ($this->help)) { $res .= " ". - $this->errors[1]."\n"; - } - elseif (isset ($this->help)) - { - $res .= " ".$this->help - ."\n"; + $res .= htmlspecialchars ($this->name, ENT_QUOTES)."_help'>"; + if (isset ($this->help)) $res .= $this->help."
\n"; + if (isset ($this->errors)) $res .= $this->errors[1]; + $res .= "\n"; } $res .= " \n"; // End controls $res .= " \n"; // End form-group