You are here

function entityreference_current_field_update_instance in Entityreference Current 7

Implements hook_field_update_instance().

File

./entityreference_current.module, line 36
Prepoplates entity reference values from Current Entity(Menu Object).

Code

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

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