Module dependent on field configuration in another module

by Josh Brown   Last Updated October 11, 2018 14:07 PM - source

I have two modules that rely on the same field; A simple boolean field that represents a state for taxonomy terms. My problem is my configuration management for this. My ideal situation would be to put this field storage configuration in my site's config directory and then both modules' info files specify a configuration dependency (using the field config's ID) on this field. But I cannot get it working.

This is what I have tried to far in both my module's info files:

  - taxonomy
  - config: 
    - taxonomy_term.field_my_field


  - taxonomy_term.field_my_field

For both of these methods, the file is among the rest of the site's config. I can move it to either module's config/install directories and it makes no difference.

My field's storage config file is as so:

uuid: 8e23dc90-2da9-4824-9783-093181987869
langcode: en
status: true
    - taxonomy
  default_config_hash: pr_yX1hCVsd_ni59pjsAQh5n7hCJ2eAnPNzJCBCHJig
id: taxonomy_term.field_my_field
field_name: field_my_field
entity_type: taxonomy_term
type: boolean
settings: {  }
module: core
locked: false
cardinality: 1
translatable: true
indexes: {  }
persist_with_no_fields: false
custom_storage: false

So my question is, what is generally the best practice for managing a single piece of configuration that's required by 2+ modules?

Related Questions

Using Configuration API in drupal 8

Updated June 15, 2015 23:03 PM

Config folder in drupal8

Updated April 13, 2016 08:03 AM