2

I'm expanding my Craft website with a small Module, internal to this project. The module currently only defines a new input-field (extending craft\base\Field).

I have dumped the autoloader from composer and my config/app.php only contains the registration of this module:

<?php
return [
    'modules' => [
        'simple-markdown-editor' => [
            'class' => \codeisland\simplemde\MarkdownModule::class,
        ],
    ],
    'bootstrap' => ['simple-markdown-editor'],
];

This setup works and the new field shows up in the Admin CP. But: as far as I understand the bootstrap-entry, it's only needed if the module needs to be executed on every page render. The Craft documentation says as much:

TIP: If your module doesn’t need to get loaded on every request, you can remove its ID from the bootstrap array.

Since the module only defines an input-field for the Admin CP, it doesn't need to be loaded on every request. But if I remove it from the bootstrap-array, it's not loaded at all.

Do I need to add additional config? Or am I just misunderstanding the documentation?

Lukas Knuth
  • 131
  • 4
  • I’ve experienced this too. Curious to know if this is a bug, a documentation error, or if there is some legitimate workaround. – Lindsey D Jun 15 '19 at 16:20

1 Answers1

2

It does in fact need to be loaded on every request, because otherwise your EVENT_REGISTER_FIELD_TYPES event listener wouldn’t get registered, which is responsible for telling Craft that the field type exists.

Brandon Kelly
  • 34,307
  • 2
  • 71
  • 137