4

Perhaps someone with a bit more Features expertise can help me here.

I have a Drupal site with 25 or so Paragraph types that I would like to export (one by one) to its own contained Feature.

I installed the latest version of Features, and created a new bundle called Paragraphs. In this new bundle, I enabled Paragraphs as a Base Type so they are an exportable option.

I go back to the main Features admin, and click "Create new feature". I fill out the basic info here, the name of the feature, then I select the Paragraph Type I want to export and wait for all of the required dependencies to auto populate. I finish the export by clicking on "Write" which produces the module folder.

In the new Drupal site I want to import it to, I see it in the list of Features. When I go to enable the module, I get an error like:

Error importing field.field.paragraph.text_editor.field_rich_text : Attempt to create a field field_rich_text that does not exist on entity type paragraph.

Except... this Feature should be introducing this field into the application and install it. The Paragraph just has a long text field for CKEditor, and there is no field.storage.paragraph.field_rich_text.yml file that is exported. Yet, field.storage.paragraph.field_rich_text is listed as a config dependency in the same said Feature.

Did I miss a step here? I basically want to export my Paragraph types as if they were Node types. I want to install them into a new Drupal installation without wiring them to any reference fields or Node types - I want to do that later.

Why am I getting errors like Attempt to create a field field_rich_text that does not exist on entity type paragraph.? I get a similar error for each Paragraph I try to enable, which are all made up of basic fields and nothing special.

Note: it looks like the auto detection doesn't quite work. For example, if I pick one of the Paragraphs from the list of non-exported Features on the overview page, the field storage definitions that are marked as a dependency in the output are NOT selected for being exported here.

I started over and removed all the exported Features, and created a new Feature. This time, when I picked the paragraph type, it still did not include the field storage definition for the field that is being bundled. When I selected it, exported it, this time it enabled on the new site, no error.

What is the proper way to do this? Do I have to go through one by one and simply ensure the field storage(s) are exported myself?

1
  • 1
    You need to export 4 things when exporting a field. 1. field storage 2. field itself 3. entity_view display 4. entity_form_display you can either use features or drupal inbuilt config export More info here drupal.org/docs/8/api/entity-api/…
    – JayKandari
    May 2, 2017 at 7:02

1 Answer 1

0

My best answer to this question is: Features is awesome but a little buggy, or seemingly so, due to field and field storage dependencies. The best solution I have found in Drupal using features and all these export issues is to create a content type where you create ALL your field base instances. I always call mine xxxFields. Then in all other content types, always add an "existing" field. really all this is doing is helping with user error. I have used features from 7 and now into 8, and I find that most issues arise through configuration of numerous content types which share fields, which creates dependency issues when trying to export features modules.

I believe your specific issue may be that that module is trying to create itself but has a dependency for a field base and field storage configuration that was created in another content type.

4
  • My best practice advice is, definitely create this fields content type to hold all your field bases. But keep it simple since you are using Paragraphs. Create fields called h2, h3, p, li, image_single, image_multiple, etc... and reuse those throughout your other paragraphs. You can always change labels for particular instances, and with theming and templating an h2 field can become anything. Even with 25 Paragraphs, you could really have only half a dozen fields...
    – Preston
    Oct 11, 2017 at 22:06
  • Your practice then would be... need a new paragraph? Create it and use existing fields. Does it require a unique field? Create the field first in the xxxFields content type, then use the existing field in your Paragraph. Just ensure to import your xxxFields feature module before you install the new Paragraph feature module.
    – Preston
    Oct 11, 2017 at 22:08
  • Sorry, I am saying content types and Paragraph types. But this applies to both. Each should have this fields type.
    – Preston
    Oct 11, 2017 at 23:23
  • Please simply edit your answer and incorporate your comments there. It's much easier to read and to follow your thoughts there.
    – leymannx
    Jan 8, 2019 at 21:09

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.