Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-05-24T07:14:35.703Z
Answers.Text: 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.
Answers.UserDisplayName: Matthias
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-05-23T20:57:09.910Z
Answers.LastActivityDate: 2024-05-23T20:57:09.910Z
Answers.UserDisplayName: Leo Leoncio
Body: <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>
  
Tags: <plugin-development><modules><craft5>
Title: EVENT_REGISTER_SITE_URL_RULES not working
ThreadText: # 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.
  
  ```
            <form method="post" accept-charset="UTF-8" novalidate>
              {{ csrfInput() }}
              {{ actionInput('/api/newsletter/subscribe') }}
              <input type="email" name="email">
              <button type="submit">Inschrijven</button>
            </form>
  
  ```
  
  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.  
  
  ---
  
  