How do you programmatically delete a field?

by liquidcms   Last Updated January 13, 2018 20:07 PM

How do you delete a field in D8?

I found this page: https://www.drupal.org/node/2012896 which lists this:

// Deleting field storage.
FieldStorageConfig::loadByName('entity_type', 'field_name')->delete();

// Deleting field.
FieldConfig::loadByName('entity_type', 'bundle', 'field_name')->delete();

but, of course, I get: Fatal error: Class 'FieldStorageConfig' not found.

Any hints as to how this gets used?

Tags : fields


Related Questions



How would I create conditional fields on install?

Updated October 13, 2016 09:03 AM


D8 - edit fields on display node

Updated March 05, 2018 22:07 PM