field_attach_form_validate

Versions
7
field_attach_form_validate($obj_type, $object, $form, &$form_state)

Perform field validation against form-submitted field values.

There are two levels of validation for fields in forms: widget validation, and field validation.

  • Widget validation steps are specific to a given widget's own form

structure and UI metaphors. They are executed through FAPI's #element_validate property during normal form validation.

  • Field validation steps are common to a given field type, independently of

the specific widget being used in a given form. They are defined in the field type's implementation of hook_field_validate().

This function performs field validation in the context of a form submission. It converts field validation errors into form errors on the correct form elements. Fieldable object types should call this function during their own form validation function.

Parameters

$obj_type The type of $object; e.g. 'node' or 'user'.

$object The object being submitted. The 'bundle', 'id' and (if applicable) 'revision' keys should be present. The actual field values will be read from $form_state['values'].

$form The form structure.

$form_state An associative array containing the current state of the form.

Related topics

▾ 5 functions call field_attach_form_validate()

comment_form_validate in modules/comment/comment.module
Validate comment form submissions.
field_test_entity_form_validate in modules/field/tests/field_test.entity.inc
Validate handler for field_test_entity_form().
node_form_validate in modules/node/node.pages.inc
taxonomy_form_term_validate in modules/taxonomy/taxonomy.admin.inc
Validation handler for the term form.
user_profile_form_validate in modules/user/user.pages.inc
Validation function for the user account and profile editing form.

Code

modules/field/field.attach.inc, line 739

<?php
function field_attach_form_validate($obj_type, $object, $form, &$form_state) {
  // Extract field values from submitted values.
  _field_invoke_default('extract_form_values', $obj_type, $object, $form, $form_state);

  // Perform field_level validation.
  try {
    field_attach_validate($obj_type, $object);
  }
  catch (FieldValidationException $e) {
    // Pass field-level validation errors back to widgets for accurate error
    // flagging.
    _field_invoke_default('form_errors', $obj_type, $object, $form, $e->errors);
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.