You are here

function entityreference_prepopulate_field_create_instance in Entityreference prepopulate 7

Implements hook_field_create_instance().

Add "default value function" setting to the field instance. We have to do it from this hook, as we don't have another chance of setting this option via the hook_field_info().

File

./entityreference_prepopulate.module, line 35
Prepopulate entity reference values from URL.

Code

function entityreference_prepopulate_field_create_instance($instance) {
  if (empty($instance['settings']['behaviors']['prepopulate']['status'])) {
    return;
  }
  $instance['default_value_function'] = 'entityreference_prepopulate_field_default_value';
  field_update_instance($instance);
}