You are here

function pmticket_update_7301 in Drupal PM (Project Management) 8

Same name and namespace in other branches
  1. 7.3 pmticket/pmticket.install \pmticket_update_7301()

Add entityreference_prepopulate behaviour to pm_assigned.

File

pmticket/pmticket.install, line 94
Installation functions for the Project Management project module.

Code

function pmticket_update_7301() {
  $entity_type = 'node';
  $bundle_name = 'pmticket';

  // Get defaults from the configurations.
  module_load_include('inc', 'pmticket', 'includes/pmticket.field_base');
  module_load_include('inc', 'pmticket', 'includes/pmticket.field_instance');
  $field_bases = pmticket_default_field_bases();
  $field_instances = pmticket_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-pmticket-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);
}