You are here

function serial_field_create_instance in Serial Field 7

Implements hook_field_create_instance().

File

./serial.module, line 53
The Serial module main file.

Code

function serial_field_create_instance(array $instance) {
  $field = field_read_field($instance['field_name']);
  if (SERIAL_FIELD_TYPE === $field['type']) {

    // Create the assistant table:
    module_load_include('inc', 'serial');
    _serial_create_table($field, $instance);

    // Set serial values for old objects.
    $old_count = _serial_init_old_entities($instance['entity_type'], $instance['bundle'], $field['field_name']);
    if ($old_count > 0) {
      drupal_set_message(t('Serial values have been automatically set for %count existing entities.', array(
        '%count' => $old_count,
      )));
    }
  }
}