Last active
August 30, 2022 19:50
-
-
Save ruby232/4d7bfd0a6282ab9be2fb7be0d220bd79 to your computer and use it in GitHub Desktop.
Delete a field in entity type programatically
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Drupal\field\Entity\FieldStorageConfig; | |
use Drupal\field\Entity\FieldConfig; | |
// Deleting field storage. | |
FieldStorageConfig::loadByName('entity_type', 'field_name')->delete(); | |
// Deleting field. | |
FieldConfig::loadByName('entity_type', 'bundle', 'field_name')->delete(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tomado de https://drupal.stackexchange.com/a/253714/24034