form_set_error($name = NULL, $message = '', $reset = FALSE)
drupal/includes/form.inc, line 790
File an error against a form element.
$name The name of the form element. If the #parents property of your form element is array('foo', 'bar', 'baz') then you may set an error on 'foo' or 'foo][bar][baz'. Setting an error on 'foo' sets an error for every element where the #parents array starts with 'foo'.
$message The error message to present to the user.
$reset Reset the form errors static cache.
Never use the return value of this function, use form_get_errors and form_get_error instead.
| Name | Description |
|---|---|
| Form generation | Functions to enable the processing and display of HTML forms. |
function form_set_error($name = NULL, $message = '', $reset = FALSE) {
static $form = array();
if ($reset) {
$form = array();
}
if (isset($name) && !isset($form[$name])) {
$form[$name] = $message;
if ($message) {
drupal_set_message($message, 'error');
}
}
return $form;
}