You are here

function entityreference_prepopulate_field_update_instance in Entityreference prepopulate 7

Implements hook_field_update_instance().

File

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

Code

function entityreference_prepopulate_field_update_instance($instance, $prior_instance) {
  if (empty($instance['settings']['behaviors']['prepopulate'])) {
    return;
  }
  if (isset($prior_instance['settings']['behaviors']['prepopulate']['status']) && $instance['settings']['behaviors']['prepopulate']['status'] == $prior_instance['settings']['behaviors']['prepopulate']['status']) {

    // Nothing changed.
    return;
  }
  $instance['default_value_function'] = !empty($instance['settings']['behaviors']['prepopulate']['status']) ? 'entityreference_prepopulate_field_default_value' : '';
  field_update_instance($instance);
}