Hot answers tagged

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 ...
Rob Erskine's user avatar
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 ...
gioppe's user avatar
  • 414
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 ...
Ben Parizek's user avatar
  • 13.4k
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 ...
Luke Pearce's user avatar
  • 3,863
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 ...
Tam's user avatar
  • 389
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;
Chattervast's user avatar
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/
odlh's user avatar
  • 31
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 ...
August Miller's user avatar
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" ...
user9975's user avatar
  • 534
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. ...
aodihis's user avatar
  • 721
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 { ...
Mats Mikkel Rummelhoff's user avatar
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 ...
Luke's user avatar
  • 521
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?
Oli's user avatar
  • 7,410
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://...
odlh's user avatar
  • 31
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 ...
RitterKnight's user avatar
  • 6,582
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 ...
Ben Croker's user avatar
  • 7,266
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 ...
korben's user avatar
  • 111
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 ...
Brad Bell's user avatar
  • 67.2k
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 (...
Mostafa Soufi's user avatar
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 */ ...
Robin Schambach's user avatar
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(""); ...
Tom De Smet's user avatar
  • 1,456

Only top scored, non community-wiki answers of a minimum length are eligible