1. drupal
    1. 8
    2. 7
7 – 8 field_delete_field($field_name)

Marks a field and its instances and data for deletion.


$field_name The field name to delete.

Related topics

▾ 9 functions call field_delete_field()

comment_uninstall in modules/comment/comment.install
Implements hook_uninstall().
FieldCrudTestCase::testDeleteField in modules/field/tests/field.test
Test the deletion of a field.
field_delete_instance in modules/field/
Marks a field instance and its data for deletion.
FileFieldValidateTestCase::testFileExtension in modules/file/tests/file.test
Test the file extension, do additional checks if mimedetect is installed.
FileFieldValidateTestCase::testFileMaxSize in modules/file/tests/file.test
Test the max file size validator.
FileFieldValidateTestCase::testRequired in modules/file/tests/file.test
Test required property on file fields.
forum_uninstall in modules/forum/forum.install
Implements hook_uninstall().
ListFieldTestCase::testUpdateAllowedValues in modules/field/modules/list/tests/list.test
Test that allowed values can be updated.
node_example_uninstall in examples/node_example/node_example.install
Implements hook_uninstall().


modules/field/, line 388

function field_delete_field($field_name) {
  // Delete all non-deleted instances.
  $field = field_info_field($field_name);
  if (isset($field['bundles'])) {
    foreach ($field['bundles'] as $entity_type => $bundles) {
      foreach ($bundles as $bundle) {
        $instance = field_info_instance($entity_type, $field_name, $bundle);
        field_delete_instance($instance, FALSE);

  // Mark field data for deletion.
  module_invoke($field['storage']['module'], 'field_storage_delete_field', $field);

  // Mark the field for deletion.
    ->fields(array('deleted' => 1))
    ->condition('field_name', $field_name)

  // Clear the cache.

  module_invoke_all('field_delete_field', $field);