Unable to install farmOS Species vocabulary, core.entity_form_display.taxonomy_term.plant_type.default, core.entity_view_display.taxonomy_term.plant_type.default already exist in active configuration
I implemented the hook_preinstall in order to delete this config before installing the module (the hook_install will create them again with the new configuration), but looks like this preinstall never runs. If I delete that configuration with drush, I can install the module and works fine.
It would not be good form to delete this configuration. If someone had customized it themselves on their instance, and then installed your module, it would wipe out their customizations.
Unfortunately, this is one of the reasons I dislike those two types of config (it’s an issue I have with Drupal core upstream - which we don’t have much control of in farmOS). They need to include information about ALL fields on an entity type. But in farmOS that’s tricky because we can never know what modules are installed, and therefore what fields need to be included in the config.
The only “proper” way to make the changes you want would be to load the config in hook_install()
(and hook_uninstall()
), modify it in PHP (ONLY the bits relevant to your module), and save it.
Although, come to think of it, there is another variable at play here: the farm_update
module will automatically revert “overridden” config when the cache gets cleared. So what I suggested wouldn’t work either.
You’ve picked a particularly thorny bit to work on here @c4ndel4, I’m sorry to say. But we were bound to run into it eventually I suppose.
Perhaps https://www.drupal.org/project/farm/issues/3190851 is going to be necessary, after all.
Or we hold our breath for this upstream Drupal core issue: https://www.drupal.org/project/drupal/issues/2346347
I wish I had better guidance to provide @c4ndel4 - it’s hard to work with the view_display
and form_display
config…