<p>I have the following struggle. I tried to register my FieldType in my init function of the module.php.</p>
<pre><code>Event::on(
        Fields::class,
        Fields::EVENT_REGISTER_FIELD_TYPES,
        function(RegisterComponentTypesEvent $event) {
            $event-&gt;types[] = SweVolley_StaffelSelectFieldType::class;
        }
    );
</code></pre>
<p>The Class SweVolley_StaffelSelectFieldType.php exists in the folder: /modules/site/fields</p>
<p>The Error in the Browser:</p>
<p>Class &quot;modules\site\Event&quot; not found</p>
<p>I don't know why?</p>

CC BY-SA 4.0
2022-09-26T16:53:32.810Z
Did you import the event class at the top of your class (`use yii\base\Event;`)? Full example in this Knowledge Base article: https://craftcms.com/knowledge-base/custom-module-events
Matt Stein
CC BY-SA 4.0
2022-09-29T08:00:27.620Z
Yes I have import the class yii\base\Event
Jonathan Fuchs
<craft3><php><fieldtypes><custom-fieldtype>
Register own FieldType in Craft 3.x
# Register own FieldType in Craft 3.x

(Asked by: username_0 on 2022-09-26)

I have the following struggle. I tried to register my FieldType in my init function of the module.php.
Event::on(
        Fields::class,
        Fields::EVENT_REGISTER_FIELD_TYPES,
        function(RegisterComponentTypesEvent $event) {
            $event->types[] = SweVolley_StaffelSelectFieldType::class;
        }
    );

The Class SweVolley_StaffelSelectFieldType.php exists in the folder: /modules/site/fields
The Error in the Browser:
Class "modules\site\Event" not found
I don't know why?

**Tags:** craft3, php, fieldtypes, custom-fieldtype
> **Comments:**
> **username_1**: Did you import the event class at the top of your class (`use yii\base\Event;`)? Full example in this Knowledge Base article: https://craftcms.com/knowledge-base/custom-module-events  
> **username_0**: Yes I have import the class yii\base\Event  

---

## 0 answers

