You are here

function tablefield_field_validate in TableField 7

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

Implements hook_field_validate().

File

./tablefield.module, line 96
This module provides a set of fields that can be used to store tabular data with a node. The implementation uses a custom CCK widget.

Code

function tablefield_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
  drupal_add_css(drupal_get_path('module', 'tablefield') . '/tablefield.css');

  // 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,
    );
  }
}