I want to change a field type from term reference to entity reference
how to do that without disturbing the features default
if i delete a field and recreate, any updates to features would again change it

Comments

mh86’s picture

Status: Active » Fixed

If it's a different field, then it's best to use a different machine name for the new one. Otherwise wired things might happen.
As a next step, export the newly created field into a custom module of your website and unset the old field in hook_field_default_fields_alter(). Then all features should stay in the 'default' state.

kaizerking’s picture

could you pl post example snippet, i could not find any
i wanted to alter the organization(company name) field type to entity reference and use "entity connect" module to create organization node and maintain a single organization data for applicants and recruiters
my apologies if this request is out of context

mh86’s picture

One possibility is to remove the organization fields from the job content types and then add following code to a custom module:

/**
 * Implements hook_field_default_fields_alter().
 */
function custom_field_default_fields_alter(&$fields) {
  // Remove the organization field from the job content types.
  $organization_fields = array(
    'node-job_per_file-field_job_organization',
    'node-job_per_template-field_job_organization',
    'node-job_per_link-field_job_organization',
  );
  foreach ($organization_fields as $field) {
    if (isset($fields[$field])) {
      unset($fields[$field]);
    }
  }
}

(Note: I did not test this code)

One disadvantage of this approach: This field might be used somewhere else as well, e.g. in the job search and deleting it might lead to some problems or require a few more overrides.

An alternative to this is to use field permissions and hide the field from 'normal' users.

And one more thing: instead of coding you might give Features Override a chance. I haven't tried it for a while.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.