Questions tagged [controller]
The controller tag has no summary.
145 questions
0 votes
0 answers
44 views
Frontend Controller drops 404
I created a module for Craft to get a simple contact form. To create the module I used the make module command. Now my problem is, that the controller is not found and I get a 404 message when I ...
0 votes
0 answers
158 views
Serialization of 'Closure' is not allowed in Craft CMS
Got this error and not sure how can I fix this. // Function to get orders for a specific vendor public function getOrdersForVendor($vendorId) { $orders = $this->getAllOrdersFromWooCommerce(); ...
1 vote
1 answer
82 views
Not able to query by id
I don't get, how i should query for an entry by ID in Craft CMS 5. I have an entry in my "Article Comments" section: The Section contains the entry type "Comments Content". The ...
1 vote
1 answer
56 views
getBodyParam('email') is empty on live server
Trying to debug a form issue which is only happening on a live server (it works on our local environments). The form makes a fetch request (using Javascript) to a route in routes.php which goes to a ...
1 vote
1 answer
146 views
Can plugins have their own routes?
I'm writing a plugin. I'd like it so that a request to view the page is processed via a Controller rather than goes straight to a template (following an MVC pattern). So a GET request to the URL of ...
2 votes
2 answers
483 views
Uploading (multiple) assets to assets controller via front end with Craft 4
I'm trying to upload assets directly to a volume using the 'assets/upload' controller in a front-end form. There must have been some changes since Craft 3 and I'm running into 2 issues: Issue 1: ...
0 votes
0 answers
127 views
Creating a User without email requirement and auto-activation from a Controller
I'm working on a project where I use Craft CMS to manage user sessions and store user preferences such as site version and preferred language. However, for privacy reasons (GDPR compliance), I'm not ...
1 vote
1 answer
115 views
Is there a way to determine an element by its path or full url instead of the uri?
I'm using Craft in headless mode. It's a multisite setup different languages. I know that's it's possible to query an element by it's uri. Is there a way to check if a full path or an absolute url ...
1 vote
1 answer
73 views
How to run Sprout Forms action from a controller to implement Google reCAPTCHA?
I'm using Sprout Forms V3 on Craft 3. I'm trying to handle the submit within a controller. This choice is made to add a custom logic, to implement a Google reCAPTCHA (as the official Sprout's plugin ...
1 vote
2 answers
488 views
Sprig: how to redirect to a URL after submitting to a custom controller?
I have a multi-pages form which is submitting using Sprig plugin. The action is targeting a controller in a custom module. Each step of the form is loading using the current step stored in session. ...
1 vote
1 answer
2k views
Set "Access-Control-Allow-Origin: *" header in a controller action (CORS issues)
I send a POST request from a headless frontend to a craft controller action but the request is not going trough because of: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the ...
1 vote
1 answer
1k views
Using EventStream doesn't work because MimeType from Controller Action is always text/html
I'm trying to listen to SSE events from a controller action. I am setting the headers in the controller action with: Craft::$app->response->headers ->set('Content-Type: text/event-...
0 votes
1 answer
71 views
How can I troubleshoot why a user's initial password is being deleted after a front-end registration? [answer: it was not set in the first place]
We have a front-end registration form that was working as expected for months, and now mysteriously when someone registers they can't log in because their password is empty. Using a front-end password ...
0 votes
2 answers
716 views
Setting up and understanding a controller
I'm trying to set up a module with a controller as bit of a learning tool. The learning is not going well so far. Here is my setup: - modules - - site - - - playing - - - - Playing.php - - - - ...
0 votes
1 answer
177 views
How to use twig macro inside controller?
I want to use the macro I defined in twig inside a controller or a module. Is that possible?