4
votes
Accepted
Ajax Post to guestEntries/saveEntries from another domain
TL;DR: Turns out this was an issue with my apache config on the Craft instance.
Explanation: I did a little digging around the GuestEntriesController.php file and noticed that Craft was not picking ...
2
votes
Accepted
POSTing data into Craft
If you don't want to get into plugin controllers and actions you can replicate this format here: https://craftcms.com/docs/templating/entry-form
And trick Craft into believing your data comes from an ...
2
votes
Accepted
Is it possible to return data/models from controller to template via setRouteVariables?
I believe you are overwriting the log variable you are sending back to the template when you set log equal to the response of getPost.
From what I can see of your code, when you return variables to ...
2
votes
Express Server posting user data to Craft
You'd normally use a front-end form to create users on a Craft site. You can add fields to this form to submit more than the standard set of fields. I believe you could use the same form within your ...
2
votes
Accepted
SQLSTATE[23000]: Column 'targetId' cannot be null
I've managed to fix the issue. Originally I was converting the Blob to a File, but this was causing the upload to silently fail. So, when Craft tried to create the relation between the asset field and ...
2
votes
Hyperlinks in blog are not showing underlined
Hyperlink styles are defined in you stylesheet (CSS).
Applying the underline text-decoration property like so:
text-decoration: underline;
2
votes
CSRF token using Craft as an API
I managed to solve it using the answer August posted and created a tutorial that I hope helps others create APIs with Craft.
https://delasign.com/blog/craft-cms-api/
2
votes
Accepted
CSRF token using Craft as an API
There are a few answers about controlling CSRF protection on a per-endpoint basis, or for requests where a token needs to be created on-the-fly, but I think your question is unique.
It sounds like ...
2
votes
Accepted
404 Error Controller Action From Jquery But Not Url
From Craft CMS documentation page about requesting controller action:
when you send action as parameter, format should be without '/actions':
<input type="hidden" name="action" ...
2
votes
Accepted
What does {{ hiddenInput('enabled', '1') }} in an entry form do?
It is to generate an HTML input tag with type of hidden.
This will not appear on the screen like a normal input does.
For more information related to input type hidden, you can refer to this.
...
1
vote
Variable entry does not exist on blog post
The problem is that you're using the only keyword when including the post-blocks.twig partial template, in your blog/_entry.html template:
{% include "_includes/post-blocks.twig" with { ...
1
vote
How to process POST and entry fields when using same form for Add as Edit on front end?
This might not be the perfect solution, but I think it's the way craft itself handles it:
I was recently digging through the edit template of the categories section. Craft has only one template here ...
1
vote
How to process POST and entry fields when using same form for Add as Edit on front end?
This may not be possible but can you not just make your form itself an include and have a "create" template and another "edit" template which have their own logic but include the same base form?
1
vote
Calls to /actions return 400 Bad Request
If anyone is looking for an alternative response, you can set the csrfvalidation to false for specific actions within controllers.
Sample code for this solution can be found here on step two:
https://...
1
vote
Calls to /actions return 400 Bad Request
You're close. Just a couple minor syntax things:
remove the colon (:) before :data-fileID
$.post has 4 parameters, the dataType (in this case 'json') goes as the last parameter.
Set the url parameter ...
1
vote
plugins route post controller?
Although your question is lacking in detail, here is a shot at helping you track down the issue. The fact that GET requests are working but POST requests are not, your form is likely missing a CSRF ...
1
vote
Storing data for page in twig
I'm not exactly sure how this plugin works, but in general the best way to do this is to rely on Webhooks. You can listen for charge.succeeded events and send an email when those occur. If you're ...
1
vote
Accepted
How to handle form submissions?
Doing it through a plugin would be the easiest way.
https://docs.craftcms.com/v3/extend/plugin-guide.html
Your plugin would have a controller that the form would post to, then you'd grab the data ...
1
vote
Craft CSRF protection and Facebook Tab
Try to disable the CSRF protection by event
use Yii;
use yii\base\ActionEvent;
use yii\base\Event;
use yii\web\Controller;
Event::on(Controller::class, Controller::EVENT_BEFORE_ACTION, function (...
1
vote
Craft CSRF protection and Facebook Tab
You can disable the token for a certain controller via
use Craft;
...
Yii::$app->controller->enableCsrfValidation = false;
or inside a Controller for a certain request
/**
* @inheritdoc
*/
...
1
vote
Accepted
Bad Request with weird params
Allright, after a lot of digging into my code I finally found out what went wrong.
I used this code to clear the placeholder in my input when clicking inside them:
$(".some-class input").val("");
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
post × 27form × 6
templating × 4
entry × 3
csrf × 3
request × 3
craft3 × 2
plugin-development × 2
entries × 2
assets × 2
plugins × 2
users × 2
plugin-contactform × 2
php × 1
redactor × 1
url × 1
error-message × 1
image × 1
error × 1
emails × 1
ajax × 1
login × 1
controller × 1
javascript × 1
mysql × 1