Skip to main content
Added examples
Source Link
milkovsky
  • 5.4k
  • 37
  • 59

To remove a field from a particular bundle you can use field_delete_instance()

Marks a field instance and its data for deletion.

Example:

function my_module_update_7001() {
  if ($instance = field_info_instance('node', 'field_name', 'page'))  {
    field_delete_instance($instance, TRUE);
    field_purge_batch(1);
  }
}

To remove a field from the system completely, you can use field_delete_field()

Marks a field and its instances and data for deletion.

Example:

function my_module_update_7001() {
  field_delete_field('field_name');
  field_purge_batch(1);
}

The fields/instances are only marked for deletion, the data will actually be purged during subsequent cron runs. To purged it manually execute:

field_purge_batch(1);

To remove a field from a particular bundle you can use field_delete_instance()

Marks a field instance and its data for deletion.

To remove a field from the system completely, you can use field_delete_field()

Marks a field and its instances and data for deletion.

The fields/instances are only marked for deletion, the data will actually be purged during subsequent cron runs.

To remove a field from a particular bundle you can use field_delete_instance()

Marks a field instance and its data for deletion.

Example:

function my_module_update_7001() {
  if ($instance = field_info_instance('node', 'field_name', 'page'))  {
    field_delete_instance($instance, TRUE);
    field_purge_batch(1);
  }
}

To remove a field from the system completely, you can use field_delete_field()

Marks a field and its instances and data for deletion.

Example:

function my_module_update_7001() {
  field_delete_field('field_name');
  field_purge_batch(1);
}

The fields/instances are only marked for deletion, the data will actually be purged during subsequent cron runs. To purged it manually execute:

field_purge_batch(1);
Source Link
Clive
  • 167.9k
  • 19
  • 303
  • 337

To remove a field from a particular bundle you can use field_delete_instance()

Marks a field instance and its data for deletion.

To remove a field from the system completely, you can use field_delete_field()

Marks a field and its instances and data for deletion.

The fields/instances are only marked for deletion, the data will actually be purged during subsequent cron runs.