0

I created a custom module which creates a content type (FAQs) with a paragraph field whose type is FAQ Item (with 2 fields, title and text).

After installing the module, I have a new content type as expected.

I add this new content type (which works), but when I want to add more paragraphs, I get this error.

error

edit start

↵An AJAX HTTP error occurred.↵HTTP Result Code: 200↵Debugging information follows.↵Path: /node/add/faq?ajax_form=1↵StatusText: OK↵ResponseText:

edit end

Is there any missing configuration the module should provide?

The YAML files are inside faq/config/optional. They have been created from the UI on another site and exported.

edit 2 start

My module files and structure

img1

.info.yml file I have basic info link name, type, description, core_version_requirement and package.

.libraries.yml Am importing a JS file, inside "src-js"

.module is empty, without any php code.

.routing.yml also have basic stuff:

faq:
path: '/faqs'
defaults:
  _controller: 'Drupal\faq\Controller\GetFaqController::getFaq'
  _title: 'FAQs Page'
requirements:
  _permission: 'access content'

Inside config-optional folder I have my YML to create content type, fields and paragraph. Those .yml files I exported from another website where I create all of this and deleted "uuid" line.

img2

Then in my controller I also have basic stuff (for now).

class GetFaqController extends ControllerBase {
public function getFaq() {
    
    echo '<h1>FAQs</h1>';

    return [
        '#title' => 'test'
    ];
}

}

This is my module structure/files.

Have very basic configs, that's why I am a bit lost with this error and what I search online I found same error but it is not related.

It seems something is missing with paragraphs and ajax request to add more.

edit 2 end

edit 3 start

I have created another module, this new module only creates a paragraph type with 2 fields (title and text), then I add manually this paragraph to "Article" content type and I get same error.

Another thing I have notice, in a clean drupal site with paragrpahs module installed, when I create a paragraph type manually via backoffice and then add it to any content type works correctly, when I install my module all paragraphs fields stop working and give this error.

If I uninstall my module and delete paragraph type created by my module, other paragraphs type start working again.

Here a repository of my custom module if someone want to test.

https://gitlab.com/drase15/custom-module

edit 3 end

12
  • It would help if the error message were completely quoted, not shown in a screenshot.
    – avpaderno
    Commented Dec 18, 2020 at 19:02
  • 1
    The Ajax error message is often not really helpful. Try taking a look at Reports > recent log messages under /admin/reports/dblog for some first debugging info
    – Hudri
    Commented Dec 21, 2020 at 13:11
  • @Hudri I don't get any message under "recent log messages", paragraphs module use ajax when adds another item, but the ajax is not working (for some reason idk), it is nothing to do with "server side"/php, I think is kind of backoffice "client side" :/
    – Pedro
    Commented Dec 21, 2020 at 13:41
  • Since you are developing, you'd definitely switch off JS/CSS aggregation and cache. And without seeing the custom module and the exact code you used to create the content type and paragraph types it's probably more like finding the needle in a haystack, sorry.
    – leymannx
    Commented Dec 23, 2020 at 12:22
  • hey @leymannx I have disabled JS/CSS aggregation and cache. Also added more information about my module structure and files
    – Pedro
    Commented Dec 23, 2020 at 13:28

1 Answer 1

0

After a lot of digging I just need to change a folder name -.- Changed from "optional" to "install", after that everything works as expected.

Thanks for your help.

Your Answer

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

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