<p>You need to include your module handle to the route</p>

<pre><code>module-handle/site/say
</code></pre>

<p>You also should use the correct namespace instead of <code>app/controllers</code> I suggest you to read the documentation</p>

<p>You can as well define a <a href="https://docs.craftcms.com/v3/updating-plugins.html#routing-hooks" rel="nofollow noreferrer">route</a> if you like</p>

CC BY-SA 4.0
2018-05-14T19:59:08.163Z
2018-05-14T20:10:12.400Z
2018-05-14T20:10:12.400Z
Robin Schambach
<p>I'm very new to craft and I'm having trouble finding an answer to my question (I've scoured the questions on here - but the only answers appear to be for plugins).</p>

<p>Basically, I want to submit a form to an action in a controller - which will be inside a Module.</p>

<p>I have this form in a template:</p>

<p><code>&lt;form method="post" action="" accept-charset="UTF-8"&gt;
    &lt;input type="hidden" name="action" value="site/say"&gt;
    &lt;input class="btn submit" type="submit" value="submit me"&gt;
&lt;/form&gt;
</code></p>

<p>I'm trying to get it to go to this controller (which is in modules/controllers/SiteController):</p>

<pre><code>&lt;?php

namespace app\controllers;

use yii\web\Controller;

class SiteController extends Controller
{
    // ...existing code...

    public function actionSay($message = 'Hello')
    {
        die('in say action');
    }
}
</code></pre>

<p>I'm constantly getting a 404 - I've tried different variations for the value of action, e.g. actions/site/say.
Do I need to add a route somewhere like in Laravel? 
Really, really stuck on this, any help would be appreciated.</p>

<form><controller><elementaction><classes><modules>
How to call Controller in Module?
# How to call Controller in Module?

(Asked by: username_0 on 2018-05-14)

I'm very new to craft and I'm having trouble finding an answer to my question (I've scoured the questions on here - but the only answers appear to be for plugins).
Basically, I want to submit a form to an action in a controller - which will be inside a Module.
I have this form in a template:





I'm trying to get it to go to this controller (which is in modules/controllers/SiteController):

I'm constantly getting a 404 - I've tried different variations for the value of action, e.g. actions/site/say.
Do I need to add a route somewhere like in Laravel? 
Really, really stuck on this, any help would be appreciated.

**Tags:** form, controller, elementaction, classes, modules


---

## 1 answers

### Answer by username_1 on 2018-05-14. Score: 4

You need to include your module handle to the route
module-handle/site/say

You also should use the correct namespace instead of app/controllers I suggest you to read the documentation
You can as well define a route if you like


---

