0

I've created a 'controllers' folder within the 'plugins' folder and a php file within that following the documentation

I've also created the following form:

    <form method="POST" accept-charset="UTF-8">
        {{ getCsrfInput() }}
        <input type="hidden" name="action" value="pluginName/controllerName/actionName">

        <input type="submit" value="Start poll">
    </form>

I keep getting the 'Unable to resolve the request' error.

Do you have any idea why this could be happening? Am I missing a step that's not in the documentation, like needing to register the url?

For reference, the action only contains $this->redirect('');

  • 1
    If you're not logged in, have you allowed anonymous access to the action in the controller? – Brad Bell Sep 3 '15 at 17:36
  • I am logged in at the time, but anonymous access wasn't set. I tried allowing it with no luck – user4041 Sep 3 '15 at 18:55
  • 1
    The other thing that gets people is case sensitivity. Double check the name of your plugin vs. it's class name as well as your controller and make sure they're matching what Craft is looking. – Brad Bell Sep 3 '15 at 19:46
  • I've even tried copying the code from the documentation example to no avail. Just to clarify, the folder it's meant to sit in is "craft/plugins/controllers/", right? – user4041 Sep 4 '15 at 9:43
  • 1
    Awesome... be sure and update with an official answer here when you get it sorted! :) – Brad Bell Sep 5 '15 at 15:22
3

As I thought, I was just being silly. I initially didn't realise that custom controllers need to be encapsulated within a custom plugin

I guess my mistake was going directly to the controllers documentation and missing the line that says:

To create a controller, first create a new controllers/ subfolder within your plugin’s folder

Hopefully anyone who runs into this (doubtful as I can imagine most, unlike me, will probably read the documentation properly) will find it somewhat useful

| improve this answer | |
  • my problem was, that SVN renamed my already renamed files back to the former case due to case insensitivity issues – Manticore Jan 26 '17 at 20:00
  • 1
    To add another gotcha - if you are working locally, and you pull down the production database, your plugin that was installed locally is now un-installed. This will also give you the above error - until you re-install it in the CP. – Damon May 16 '17 at 4:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy