Same name and namespace in other branches
  1. 4.7.x includes/form.inc \form_set_error()
  2. 5.x includes/form.inc \form_set_error()
  3. 6.x includes/form.inc \form_set_error()
  4. 7.x includes/form.inc \form_set_error()

File an error against the form element with the specified name.

Related topics

19 calls to form_set_error()
comment_validate_form in modules/comment.module
drupal_settings in modules/drupal.module
Implementation of hook_settings().
forum_validate in modules/forum.module
Implementation of hook_validate().
hook_validate in developer/hooks/node.php
Verify a node editing form.
menu_edit_item_validate in modules/menu.module
Confirm that an edited menu item has fields properly filled in.

... See full list

File

includes/common.inc, line 1009
Common functions that many Drupal modules will need to reference.

Code

function form_set_error($name, $message) {
  $GLOBALS['form'][$name] = $message;
  drupal_set_message($message, 'error');
}