0

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?

1 Answer 1

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

1
  • 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
    Commented May 24 at 7:14

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.