Skip to main content
1 of 2

What @leymannx answer is missing is explanation of what can (and should) be shipped with a custom module and what cannot.

Field storage can and should be shipoped with your module.

Field instance may be shipped with your module, but only as optional, as it would depend on other modules providing content types (unless your module provides boths content type and fields in which case you may just provide in config/install). Btw, you may store these files either in this or other module - when enabled, Drupal will scan all config/optional dirs for all modules to pickup any relevant configuration. https://www.drupal.org/node/2453919

Entity form display cannot be shipped with your module. Moreover, if your module provides just a field, shipping entit form display for the whole entity would override existing configuration. Instead, your module must include implementation of hook_install() where fields will be altered for form display for all supported content types.

Entity view display should be treated the same way as entity form display.