The verifier()
function is used to analyse the values posted and return errors that may exist concerning the data entered. To do this, the function returns a paired "field" / "error message" array of the offending fields, and also possibly a general message for the whole of the form using the "message_erreur" key.
The form processing function will be called on ONLY if the table returned is empty. If it is not, the form is redisplayed with the various error messages that have been passed.
function formulaire_nom_verifier_dist() {
$erreurs = array();
foreach(array('titre','texte') as $champ) {
if (!_request($champ)) {
$erreurs[$champ] = "This data is mandatory!";
}
}
if (count($erreurs)) {
$erreurs['message_erreur'] = "An error occured in your data entry";
}
return $erreurs;
}
The formulaire_verifier pipeline is used to supplement the list of returned errors.