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
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 