6

I have used featured to create a yml file for views and other configurations. When I import my yml file all that is created is a content type that has a title. Is there a way to import the fields with the content type?

uuid: 1bd0f08e-cf80-4fc3-8707-7a9d19c404da
langcode: en
status: true
dependencies:
  module:
    - menu_ui
third_party_settings:
  menu_ui:
    available_menus:
      - main
    parent: 'main:'
name: Podcast
type: podcast
description: 'Allows Drupal to play an audio file.  The Embed Podcast field should contain the name of the Podcast exactly as it is uploaded to Drupal.'
help: ''
new_revision: false
preview_mode: 1
display_submitted: true

this is my file and there is nothing about the fields in a content type

1 Answer 1

9

To add a field to custom content type you need

  1. field.field.node.content-type.field-name.yml
  2. field.storage.node.field-name.yml

The easiest way for you is create the content type and fields via UI and then just simply export it in admin/config/development/configuration/single/export (you have to install the config core module). Then remove uuid and you are done.

While exporting, export following configuration types..

  • Content Type
  • Entity form display
  • Entity view display
  • Field
  • Field Storage

Hope this will help you.

8
  • quick question. is this possible if i put it in a module? I tired to put it in a module and put all the files in module/config/install but my module wont stay installed. am i missing a file or is that the wrong way to do this? Oct 21, 2015 at 19:32
  • you can do it by placeing all .yml files in module/config/install folder. It worked for me.
    – Abin
    Oct 22, 2015 at 3:59
  • I will check for misspellings or something then. The when i try to install the module it wont install. no errors show up or anything it just doesnt install Oct 22, 2015 at 13:22
  • In modules page it showing as enabled..??
    – Abin
    Oct 26, 2015 at 6:33
  • no. when i click the enable the page reloads and the module shows up as not enabled Oct 26, 2015 at 13:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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