You are here

function tablefield_field_validate in TableField 7.3

Same name and namespace in other branches
  1. 7 tablefield.module \tablefield_field_validate()
  2. 7.2 tablefield.module \tablefield_field_validate()

Implements hook_field_validate().

File

./tablefield.module, line 527
Provides a set of fields that can be used to store tabular data with a node.

Code

function tablefield_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {

  // Catch empty form submissions for required tablefields.
  if ($instance['required'] && isset($items[0]) && tablefield_field_is_empty($items[0], $field)) {
    $message = t('@field is a required field.', array(
      '@field' => $instance['label'],
    ));
    $errors[$field['field_name']][$langcode][0]['tablefield'][] = array(
      'error' => 'empty_required_tablefield',
      'message' => $message,
    );
  }
}