BUG form : allow the values and the errors to be displayed
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2187 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
90
form.php
90
form.php
@@ -154,6 +154,12 @@ class form
|
||||
}
|
||||
|
||||
$res .=" ";
|
||||
if (isset ($values[$field->name]) &&
|
||||
$values[$field->name] !== "unset")
|
||||
$field->values = $values[$field->name];
|
||||
if (isset ($errors[$field->name]) &&
|
||||
$errors[$field->name] !== "unset")
|
||||
$field->errors = $errors[$field->name];
|
||||
$res .= $field->display ();
|
||||
}
|
||||
|
||||
@@ -235,8 +241,8 @@ class formfield
|
||||
// No $this->multiple, $this->rows $this->cols
|
||||
$res = "";
|
||||
$res .= "<div class='form-group";
|
||||
if (isset ($errors[$this->name]))
|
||||
$res .= " has-".$errors[$this->name][0];
|
||||
if (isset ($this->errors))
|
||||
$res .= " has-".$this->errors[0];
|
||||
$res .= "'>\n";
|
||||
$res .= " <label class='col-sm-2 control-label' for='".
|
||||
$this->formName."_";
|
||||
@@ -267,8 +273,8 @@ class formfield
|
||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."_$key'";
|
||||
if (isset ($this->readonly) && $this->readonly !== FALSE)
|
||||
$res .= " disabled='disabled'";
|
||||
if (isset ($values[$this->name][$key]) &&
|
||||
$values[$this->name][$key] !== "unset")
|
||||
if (isset ($this->values[$key]) &&
|
||||
$this->values[$key] !== "unset")
|
||||
$res .= " checked='checked'";
|
||||
elseif (isset ($this->defaults[$key]) &&
|
||||
$this->defaults[$key] !== "")
|
||||
@@ -280,8 +286,8 @@ class formfield
|
||||
$res .= "$val\n";
|
||||
}
|
||||
|
||||
if (isset ($errors[$this->name]))
|
||||
$res .= " <span class='help-block'>".$errors[$this->name][1].
|
||||
if (isset ($this->errors))
|
||||
$res .= " <span class='help-block'>".$this->errors[1].
|
||||
"</span>\n";
|
||||
$res .= " </div>\n"; // End controls
|
||||
$res .= " </div>\n"; // End form-group
|
||||
@@ -299,8 +305,8 @@ class formfield
|
||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."]'";
|
||||
$res .= " id='$this->formName"."_";
|
||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."'";
|
||||
if (isset ($values[$this->name]))
|
||||
$res .= " value='".htmlspecialchars ($values[$this->name])."'";
|
||||
if (isset ($this->values))
|
||||
$res .= " value='".htmlspecialchars ($this->values)."'";
|
||||
else
|
||||
$res .= " value='".htmlspecialchars ($this->defaults)."'";
|
||||
$res .= "/>\n";
|
||||
@@ -313,8 +319,8 @@ class formfield
|
||||
$res = "";
|
||||
// No $this->multiple, $this->rows $this->cols
|
||||
$res .= "<div class='form-group";
|
||||
if (isset ($errors[$this->name]))
|
||||
$res .= " has-".$errors[$this->name][0];
|
||||
if (isset ($this->errors))
|
||||
$res .= " has-".$this->errors[0];
|
||||
$res .= "'>\n";
|
||||
$res .= " <label class='col-sm-2 control-label' for='".
|
||||
$this->formName."_";
|
||||
@@ -334,8 +340,8 @@ class formfield
|
||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."]'";
|
||||
$res .= " id='$this->formName"."_";
|
||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."'";
|
||||
if (isset ($values[$this->name]))
|
||||
$res .= " value='".htmlspecialchars ($values[$this->name],
|
||||
if (isset ($this->values))
|
||||
$res .= " value='".htmlspecialchars ($this->values,
|
||||
ENT_QUOTES)."'";
|
||||
else
|
||||
$res .= " value='".htmlspecialchars ($this->defaults, ENT_QUOTES).
|
||||
@@ -346,8 +352,8 @@ class formfield
|
||||
if (isset ($this->hidden) && $this->hidden !== FALSE)
|
||||
$res .= " style='display:none'";
|
||||
$res .= "/>\n";
|
||||
if (isset ($errors[$this->name]))
|
||||
$res .= " <span class='help-block'>".$errors[$this->name][1].
|
||||
if (isset ($this->errors))
|
||||
$res .= " <span class='help-block'>".$this->errors[1].
|
||||
"</span>\n";
|
||||
$res .= " </div>\n"; // End controls
|
||||
$res .= " </div>\n"; // End form-group
|
||||
@@ -360,8 +366,8 @@ class formfield
|
||||
$res = "";
|
||||
// No $this->multiple, $this->rows $this->cols
|
||||
$res .= "<div class='form-group";
|
||||
if (isset ($errors[$this->name]))
|
||||
$res .= " has-".$errors[$this->name][0];
|
||||
if (isset ($this->errors))
|
||||
$res .= " has-".$this->errors[0];
|
||||
$res .= "'>\n";
|
||||
$res .= " <label class='col-sm-2 control-label' for='".
|
||||
$this->formName."_";
|
||||
@@ -394,8 +400,8 @@ class formfield
|
||||
$res .= " value='".htmlspecialchars ($val, ENT_QUOTES)."'";
|
||||
if (isset ($this->readonly) && $this->readonly !== FALSE)
|
||||
$res .= " readonly='readonly'";
|
||||
if (isset ($values[$this->name]) &&
|
||||
$values[$this->name] === $val)
|
||||
if (isset ($this->values) &&
|
||||
$this->values === $val)
|
||||
$res .= " checked='checked'";
|
||||
elseif (isset ($this->defaults[0]) &&
|
||||
$this->defaults[0] === $val)
|
||||
@@ -408,8 +414,8 @@ class formfield
|
||||
$res .= "</label>\n"; // End label radio
|
||||
}
|
||||
|
||||
if (isset ($errors[$this->name]))
|
||||
$res .= " <span class='help-block'>".$errors[$this->name][1].
|
||||
if (isset ($this->errors))
|
||||
$res .= " <span class='help-block'>".$this->errors[1].
|
||||
"</span>\n";
|
||||
$res .= " </div>\n"; // End controls
|
||||
$res .= " </div>\n"; // End form-group
|
||||
@@ -422,8 +428,8 @@ class formfield
|
||||
$res = "";
|
||||
// $values->$this, $this->cols
|
||||
$res .= "<div class='form-group";
|
||||
if (isset ($errors[$this->name]))
|
||||
$res .= " has-".$errors[$this->name][0];
|
||||
if (isset ($this->errors))
|
||||
$res .= " has-".$this->errors[0];
|
||||
$res .= "'>\n";
|
||||
$res .= " <label class='col-sm-2 control-label' for='".
|
||||
$this->formName."_";
|
||||
@@ -484,13 +490,13 @@ class formfield
|
||||
{
|
||||
$res .= " <option value='";
|
||||
$res .= htmlspecialchars ($key, ENT_QUOTES)."'";
|
||||
if (isset ($values[$this->name]) &&
|
||||
is_string ($values[$this->name]) &&
|
||||
$values[$this->name] == $key)
|
||||
if (isset ($this->values) &&
|
||||
is_string ($this->values) &&
|
||||
$this->values == $key)
|
||||
$res .= " selected='selected'";
|
||||
elseif (isset ($values[$this->name]) &&
|
||||
is_array ($values[$this->name]) &&
|
||||
in_array ($key, $values[$this->name]))
|
||||
elseif (isset ($this->values) &&
|
||||
is_array ($this->values) &&
|
||||
in_array ($key, $this->values))
|
||||
$res .= " selected='selected'";
|
||||
$res .= ">";
|
||||
$res .= htmlspecialchars ($val);
|
||||
@@ -498,8 +504,8 @@ class formfield
|
||||
}
|
||||
|
||||
$res .= " </select>\n";
|
||||
if (isset ($errors[$this->name]))
|
||||
$res .= " <span class='help-block'>".$errors[$this->name][1].
|
||||
if (isset ($this->errors))
|
||||
$res .= " <span class='help-block'>".$this->errors[1].
|
||||
"</span>\n";
|
||||
}
|
||||
else
|
||||
@@ -547,8 +553,8 @@ class formfield
|
||||
$res = "";
|
||||
// No $this->multiple, $this->titles
|
||||
$res .= "<div class='form-group";
|
||||
if (isset ($errors[$this->name]))
|
||||
$res .= " has-".$errors[$this->name][0];
|
||||
if (isset ($this->errors))
|
||||
$res .= " has-".$this->errors[0];
|
||||
$res .= "'>\n";
|
||||
$res .= " <label class='col-sm-2 control-label' for='".
|
||||
$this->formName."_";
|
||||
@@ -580,13 +586,13 @@ class formfield
|
||||
$this->rows = 4;
|
||||
$res .= " rows='".$this->rows."'";
|
||||
$res .= ">";
|
||||
if (isset ($values[$this->name]))
|
||||
$res .= htmlspecialchars ($values[$this->name], ENT_QUOTES);
|
||||
if (isset ($this->values))
|
||||
$res .= htmlspecialchars ($this->values, ENT_QUOTES);
|
||||
else
|
||||
$res .= htmlspecialchars ($this->defaults, ENT_QUOTES);
|
||||
$res .= "</textarea>\n";
|
||||
if (isset ($errors[$this->name]))
|
||||
$res .= " <span class='help-block'>".$errors[$this->name][1].
|
||||
if (isset ($this->errors))
|
||||
$res .= " <span class='help-block'>".$this->errors[1].
|
||||
"</span>\n";
|
||||
$res .= " </div>\n"; // End controls
|
||||
$res .= " </div>\n"; // End form-group
|
||||
@@ -599,8 +605,8 @@ class formfield
|
||||
$res = "";
|
||||
// No $this->multiple, $this->titles, $this->rows, $this->cols
|
||||
$res .= "<div class='form-group";
|
||||
if (isset ($errors[$this->name]))
|
||||
$res .= " has-".$errors[$this->name][0];
|
||||
if (isset ($this->errors))
|
||||
$res .= " has-".$this->errors[0];
|
||||
$res .= "'>\n";
|
||||
$res .= " <label class='col-sm-2 control-label' for='".
|
||||
$this->formName."_";
|
||||
@@ -620,8 +626,8 @@ class formfield
|
||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."]'";
|
||||
$res .= " id='$this->formName"."_";
|
||||
$res .= htmlspecialchars ($this->name, ENT_QUOTES)."'";
|
||||
if (isset ($values[$this->name]))
|
||||
$res .= " value='".htmlspecialchars ($values[$this->name],
|
||||
if (isset ($this->values))
|
||||
$res .= " value='".htmlspecialchars ($this->values,
|
||||
ENT_QUOTES)."'";
|
||||
else
|
||||
$res .= " value='".htmlspecialchars ($this->defaults, ENT_QUOTES).
|
||||
@@ -632,8 +638,8 @@ class formfield
|
||||
if (isset ($this->hidden) && $this->hidden !== FALSE)
|
||||
$res .= " style='display:none'";
|
||||
$res .= "/>\n";
|
||||
if (isset ($errors[$this->name]))
|
||||
$res .= " <span class='help-block'>".$errors[$this->name][1].
|
||||
if (isset ($this->errors))
|
||||
$res .= " <span class='help-block'>".$this->errors[1].
|
||||
"</span>\n";
|
||||
$res .= " </div>\n"; // End controls
|
||||
$res .= " </div>\n"; // End form-group
|
||||
|
||||
Reference in New Issue
Block a user