0

I have a custom module. On its installation I want to set some configuration settings of views like:

ui.show.master_display
ui.show.sql_query.enabled

to TRUE.

For this I have added a file mymod_views.settings.yml to modules/mymod/config/install/. the content of the file is:

ui:
  show:
    additional_queries: true
    advanced_column: true
    master_display: true
    performance_statistics: true
    preview_information: true
    sql_query:
      enabled: true
      where: above
    display_embed: false
  always_live_preview: false

But on the installation of the module I am getting the following exception.

exception 'Drupal\Core\Config\PreExistingConfigException' with message 'Configuration objects (mymod_views.settings) provided by mymod already
exist in active configuration' in
/var/www/drupal8/core/lib/Drupal/Core/Config/PreExistingConfigException.php:70

Can someone tells me how I will set these options through my module?

0

It is not possible to change or override configuration from other modules like that, you can only provide new, not yet existing configuration in config/install. The only exception to that rule are install profiles.

Instead, you need to implement hook_install() and alter the configuration there. See locale_install() for example:

\Drupal::configFactory()
  ->getEditable('views_ui.settings')
  ->set('ui.show.master_display', TRUE)
  ->save();
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.