You are here

function pmissue_update_7301 in Drupal PM (Project Management) 8

Same name and namespace in other branches
  1. 7.3 pmissue/pmissue.install \pmissue_update_7301()

Add entityreference_prepopulate behaviour to pm_assigned.

File

pmissue/pmissue.install, line 83
Install, disable, uninstall and update functions for PM Issue module.

Code

function pmissue_update_7301() {
  $entity_type = 'node';
  $bundle_name = 'pmissue';

  // Get defaults from the configurations.
  module_load_include('inc', 'pmissue', 'includes/pmissue.field_base');
  module_load_include('inc', 'pmissue', 'includes/pmissue.field_instance');
  $field_bases = pmissue_default_field_bases();
  $field_instances = pmissue_default_field_instances();

  // Update pm_assigned.
  $field_name = 'pm_assigned';
  $field_base = $field_bases[$field_name];
  $base_info = array(
    'field_name' => $field_name,
    'settings' => $field_base['settings'],
  );
  field_update_field($base_info);

  // Update Field Instance.
  $field_instance = $field_instances['node-pmissue-pm_assigned'];
  $instance_info = field_info_instance($entity_type, $field_name, $bundle_name);
  $instance_info['settings']['behaviors']['prepopulate'] = $field_instance['settings']['behaviors']['prepopulate'];
  $instance_info['default_value_function'] = $field_instance['default_value_function'];
  field_update_instance($instance_info);
}