I'm working on my first Craft 3 plugin and want to add some buttons to my plugin's control panel section which post form data to a controller.
My plugin is called 'myplugin', the controller I wish to post to is called 'products' and the method in that controller is 'get-products'. I figured I should therefore create the URL on the forms as
{{ actionUrl('products/get-products') }}
However this yields a 404 error
HTTP 404 – Not Found – yii\web\NotFoundHttpException
Page not found.
↵
Caused by: Invalid Route – yii\base\InvalidRouteException
Unable to resolve the request "https:/local.mydomain.co.uk/index.php?p=admin/actions/products/get-products".
in /Users/pete/projects/myclient/dev/build/vendor/yiisoft/yii2/base/Module.php at line 537
If I call the URL directly by using https://local.mydomain.co.uk/admin/actions/myplugin/products/get-products
then it behaves as expected.
Obviously I'm missing some really important bit of knowledge here and would love if someone could help me understand what's going on.