By Shawn


2019-05-13 08:19:09 8 Comments

I have created a view and then exported it normally to a yml file. Then I put this yml file into my mycustommodule/config/install folder.

So current its named mycustommodule.view.user_assigned.yml

However when I uninstall the module and reinstall it to see if it will upload the view, it does not. What am I doing wrong?

Edit: I copied and pasted the yml file itself so there should be no errors there. The only thing I did was remove the UUID string since I read elsewhere it was not needed.

2 comments

@Hudri 2019-05-13 09:01:51

This is by concept, uninstalling a module does not remove config listed in config/install - and therefore the config also won't also update through reinstalling. (Actually I thought there even would be some error message like "can't install because config object already exists")

But you can add an enforced dependency to your config, which will delete the config object when you uninstall the module (and therefore also update it when you reinstall it).

Add this to your .yml

dependencies:
  enforced:
    module:
      - mycustommodule

@Clive 2019-05-13 09:03:56

The file is named incorrectly so the config never gets installed in the first place (hence no duplicate config error message)

@Clive 2019-05-13 09:01:39

The first part of a config item filename is the module responsible for the config type, not the module installing it.

In your case that's "views", so the file should be named views.view.user_assigned.yml.

@Shawn 2019-05-13 12:00:50

Thank you, this fixed it. I have a question though, in my original file naming convention, I put 'view' there for my own sake, to recognize this as a view and not another entity. When I did your approach, Views.view.(whatever here), it works, but if I put Views.(whatever here), it does not work. It requires Views.view. Where can I find documentation regarding this so I know how to properly name things? Otherwise, I am blind and guessing in the dark.

@Prestosaurus 2019-05-13 14:39:55

You can go to admin > config sync > export > single item. Then under the text area you will see the name of the config file once you’ve made a selection.

Related Questions

Sponsored Content

1 Answered Questions

How does Drupal attach ajax to views exposed filters? Manually rendering a view

  • 2017-03-26 00:06:27
  • RaisinBranCrunch
  • 455 View
  • 0 Score
  • 1 Answer
  • Tags:   8 views

2 Answered Questions

[SOLVED] How do I programmatically create a view in a custom module?

  • 2019-01-08 19:12:07
  • Rudi Shafakian
  • 682 View
  • 1 Score
  • 2 Answer
  • Tags:   views 8

1 Answered Questions

[SOLVED] Manually removing database records of a module

  • 2018-09-14 11:29:47
  • Menno van den Heuvel
  • 57 View
  • 0 Score
  • 1 Answer
  • Tags:   7 installing

2 Answered Questions

[SOLVED] How to uninstall a text format created by a D8 module?

  • 2015-04-15 14:11:50
  • Christoph Burschka
  • 342 View
  • 2 Score
  • 2 Answer
  • Tags:   8 input-formats

2 Answered Questions

[SOLVED] Add default image to image file programmatically

1 Answered Questions

Cannot log in site despite having credentials from settings.php

1 Answered Questions

[SOLVED] Convert your views into a custom module

  • 2012-12-06 18:14:31
  • DrupalMonster
  • 543 View
  • 1 Score
  • 1 Answer
  • Tags:   views theming 6

1 Answered Questions

1 Answered Questions

Migrating a changed view

  • 2016-06-24 14:45:50
  • Mike
  • 30 View
  • 0 Score
  • 1 Answer
  • Tags:   8 features

1 Answered Questions

[SOLVED] connect view to content type

  • 2014-05-27 20:12:12
  • open_sourse
  • 109 View
  • 0 Score
  • 1 Answer
  • Tags:   views nodes theming

Sponsored Content