<p>You're getting a 404 because your action method isn't telling Craft what do to after it has echo'd 'Here', so <a href="http://buildwithcraft.com/docs/routing" rel="nofollow">routing</a> continues.</p>

<p>See #3 is that link:</p>

<pre><code>The request doesn’t necessarily end after a controller has been called. The controller may allow it to keep going.
</code></pre>

<p>You can redirect, end the request, load up a template to display, etc.</p>

<p><strong>Update:</strong></p>

<p>The <code>controller</code> folder needs to be renamed to <code>controllers</code>.</p>

CC BY-SA 3.0
2015-03-05T21:56:49.280Z
So if I put something like `$this->redirect('http://google.com');` in my controller method it should redirect, but I'm still being returned to `/pro-portal` and getting the 404 page.
Brett DeWoody
CC BY-SA 3.0
2015-03-05T22:09:03.520Z
If you put a `die();` after the echo, do you see the text?
Brad Bell
CC BY-SA 3.0
2015-03-05T22:10:06.677Z
No. I get the 404 page.
Brett DeWoody
CC BY-SA 3.0
2015-03-05T22:11:31.363Z
Oh, it's not even making it to the action then. Rename your `controller` folder to `controllers`.
Brad Bell
CC BY-SA 3.0
2015-03-05T22:13:14.773Z
I knew it would be something simple like that. Thank you!
Brett DeWoody
CC BY-SA 3.0
2015-03-05T21:51:56.430Z
2015-03-05T22:13:50.947Z
2015-03-05T22:13:50.947Z
Brad Bell
<p>I'm working on a plugin and need a front-end (non CP) form that submits to one of the plugin controllers. Here's my setup:</p>

<pre><code>- plugins
  - portal
    -- PortalPlugin.php
    - controller
      -- Portal_AccessController.php
</code></pre>

<p><strong>Portal_AccessController.php</strong></p>

<pre><code>&lt;?php
namespace Craft;

class Portal_AccessController extends BaseController {

    protected $allowAnonymous = true;

    public function actionLogin() {

        echo 'Here';

    }

}
</code></pre>

<p>I then created a front-end form by adding a new template directory in <code>/craft/templates</code>:</p>

<pre><code>- pro-portal
  -- index.html
</code></pre>

<p>With <code>index.html</code> containing:</p>

<pre><code>&lt;form method="post" action="" accept-charset="UTF-8"&gt;
    &lt;input type="hidden" name="action" value="portal/access/login"&gt;

    &lt;div&gt;
        &lt;input type="text" maxlength="4"&gt;
        &lt;input type="text" maxlength="4"&gt;
        &lt;input type="text" maxlength="4"&gt;
        &lt;input type="text" maxlength="4"&gt;
    &lt;/div&gt;
    &lt;a href="{{ actionUrl('portal/access/login') }}"&gt;Test me&lt;/a&gt;
    &lt;input class="btn submit" type="submit" value="Submit"&gt;
&lt;/form&gt;
</code></pre>

<p>Hitting <code>mydomain.com/pro-portal</code> displays the form. On submit it returns to <code>/pro-portal</code> but with a 404 error. </p>

<p>I also tried creating an action link but that also results in a 404 at <code>/index.php/actions/portal/access/login</code>.</p>

<p>I've looked through answers on similar questions and tried all the solutions but no luck. Am I overlooking something? Missing something?</p>

CC BY-SA 3.0
2015-03-05T21:43:59.057Z
What's `$response['redirect']` and where is it coming from?
Brad Bell
CC BY-SA 3.0
2015-03-05T21:46:37.090Z
I tried passing in a redirect parameter to redirect to a new URL. That's not in my code at the moment. I've update the question to show that.
Brett DeWoody
<plugin-development><form>
Posting front-end form to plugin controller route results in 404
# Posting front-end form to plugin controller route results in 404

(Asked by: username_0 on 2015-03-05)

I'm working on a plugin and need a front-end (non CP) form that submits to one of the plugin controllers. Here's my setup:
- plugins
  - portal
    -- PortalPlugin.php
    - controller
      -- Portal_AccessController.php

Portal_AccessController.php

I then created a front-end form by adding a new template directory in /craft/templates:
- pro-portal
  -- index.html

With index.html containing:

    

    
        
        
        
        
    
    Test me
    


Hitting mydomain.com/pro-portal displays the form. On submit it returns to /pro-portal but with a 404 error. 
I also tried creating an action link but that also results in a 404 at /index.php/actions/portal/access/login.
I've looked through answers on similar questions and tried all the solutions but no luck. Am I overlooking something? Missing something?

**Tags:** plugin-development, form
> **Comments:**
> **username_1**: What's `$response['redirect']` and where is it coming from?  
> **username_0**: I tried passing in a redirect parameter to redirect to a new URL. That's not in my code at the moment. I've update the question to show that.  

---

## 1 answers

### Answer by username_1 on 2015-03-05. Score: 0 | Accepted answer

You're getting a 404 because your action method isn't telling Craft what do to after it has echo'd 'Here', so routing continues.
See #3 is that link:
The request doesn’t necessarily end after a controller has been called. The controller may allow it to keep going.

You can redirect, end the request, load up a template to display, etc.
Update:
The controller folder needs to be renamed to controllers.

> **Comments:**
> **username_0**: So if I put something like `$this->redirect('http://google.com');` in my controller method it should redirect, but I'm still being returned to `/pro-portal` and getting the 404 page.  
> **username_1**: If you put a `die();` after the echo, do you see the text?  
> **username_0**: No. I get the 404 page.  
> **username_1**: Oh, it's not even making it to the action then. Rename your `controller` folder to `controllers`.  
> **username_0**: I knew it would be something simple like that. Thank you!  

---

