<p>I believe you're missing referencing correctly the namespace as in namespace/controller/action</p>
<p>Check if 'commerce-extension' is the proper namespace...</p>
<p>I'd search within vendor folder for this MailchimpController class and double check</p>

CC BY-SA 4.0
2024-05-24T07:14:35.703Z
It is correct. But let's say it isn't. Shouldn't using `/commerce-extension/mailchimp/subscribe` as the direct actionInput in the form fail then? This works. Which leads me to believe that it is something with the routing rather than the namespace.
Matthias
CC BY-SA 4.0
2024-05-23T20:57:09.910Z
2024-05-23T20:57:09.910Z
Leo Leoncio
<p>I have created a custom module and registered a route like this.</p>
<pre><code>EVENT::on(
            UrlManager::class,
            UrlManager::EVENT_REGISTER_SITE_URL_RULES,
            function (RegisterUrlRulesEvent $event) {
                // Create mailchimp subscription
                $event-&gt;rules['api/newsletter/subscribe'] = 'commerce-extension/mailchimp/subscribe';
            }
        );
</code></pre>
<p>However when I use this in my form it always returns a 404.</p>
<pre><code>          &lt;form method=&quot;post&quot; accept-charset=&quot;UTF-8&quot; novalidate&gt;
            {{ csrfInput() }}
            {{ actionInput('/api/newsletter/subscribe') }}
            &lt;input type=&quot;email&quot; name=&quot;email&quot;&gt;
            &lt;button type=&quot;submit&quot;&gt;Inschrijven&lt;/button&gt;
          &lt;/form&gt;
</code></pre>
<p>Using an actionInput that links directly to the controller works without issues.</p>
<p><code>{{ actionInput('/commerce-extension/mailchimp/subscribe') }}</code></p>
<p>Am I doing something wrong?</p>
<p>EDIT: I just noticed that the newly registered URL works when posting to it with fetch in javascript. Maybe there is something wrong with the <code>actionInput</code>?</p>

<plugin-development><modules><craft5>
EVENT_REGISTER_SITE_URL_RULES not working
# EVENT_REGISTER_SITE_URL_RULES not working

(Asked by: username_0 on 2024-05-23)

I have created a custom module and registered a route like this.
EVENT::on(
            UrlManager::class,
            UrlManager::EVENT_REGISTER_SITE_URL_RULES,
            function (RegisterUrlRulesEvent $event) {
                // Create mailchimp subscription
                $event->rules['api/newsletter/subscribe'] = 'commerce-extension/mailchimp/subscribe';
            }
        );

However when I use this in my form it always returns a 404.
          
            {{ csrfInput() }}
            {{ actionInput('/api/newsletter/subscribe') }}
            
            Inschrijven
          

Using an actionInput that links directly to the controller works without issues.
{{ actionInput('/commerce-extension/mailchimp/subscribe') }}
Am I doing something wrong?
EDIT: I just noticed that the newly registered URL works when posting to it with fetch in javascript. Maybe there is something wrong with the actionInput?

**Tags:** plugin-development, modules, craft5


---

## 1 answers

### Answer by username_1 on 2024-05-23. Score: 0

I believe you're missing referencing correctly the namespace as in namespace/controller/action

Check if 'commerce-extension' is the proper namespace...

I'd search within vendor folder for this MailchimpController class and double check

> **Comments:**
> **username_0**: It is correct. But let's say it isn't. Shouldn't using `/commerce-extension/mailchimp/subscribe` as the direct actionInput in the form fail then? This works. Which leads me to believe that it is something with the routing rather than the namespace.  

---

