You are here

function _multifield_field_attach_form_validate in Multifield 7.2

Same name and namespace in other branches
  1. 7 multifield.field.inc \_multifield_field_attach_form_validate()

File

./multifield.field.inc, line 185
Field integration for the Multifield module.

Code

function _multifield_field_attach_form_validate($entity_type, $entity) {

  // Validate $options since this is a new parameter added after Drupal 7 was
  // released.
  $options = is_array($options) ? $options : array();

  // Extract field values from submitted values.

  //_field_invoke_default('extract_form_values', $entity_type, $entity, $form, $form_state);

  // Perform field_level validation.
  try {
    field_attach_validate($entity_type, $entity, $options);
  } catch (FieldValidationException $e) {

    // Pass field-level validation errors back to widgets for accurate error
    // flagging.
    foreach ($e->errors as $field_name => $field_errors) {
      foreach ($field_errors as $langcode => $errors) {
        $field_state = field_form_get_state($form['#parents'], $field_name, $langcode, $form_state);
        $field_state['errors'] = $errors;
        field_form_set_state($form['#parents'], $field_name, $langcode, $form_state, $field_state);
      }
    }
    _field_invoke_default('form_errors', $entity_type, $entity, $form, $form_state, $options);
  }
}