Same name and namespace in other branches
  1. 4.6.x includes/common.inc \form_set_error()
  2. 4.7.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 a form element. If the name of the element is edit[foo][bar] then you may pass either foo or foo][bar as $name foo will set an error for all its children.

Related topics

46 calls to form_set_error()
aggregator_form_category_validate in modules/aggregator/aggregator.module
Validate aggregator_form_feed form submissions.
aggregator_form_feed_validate in modules/aggregator/aggregator.module
Validate aggregator_form_feed form submissions.
block_admin_configure_validate in modules/block/block.module
block_box_form_validate in modules/block/block.module
comment_admin_overview_validate in modules/comment/comment.module
We can't execute any 'Update options' if no comments were selected.

... See full list

File

includes/form.inc, line 592

Code

function form_set_error($name = NULL, $message = '') {
  static $form = array();
  if (isset($name) && !isset($form[$name])) {
    $form[$name] = $message;
    if ($message) {
      drupal_set_message($message, 'error');
    }
  }
  return $form;
}