9
votes
Accepted
Access POST data to conditionally display form
I think you want this:
{% set success = craft.request.getPost('test') %}
{% if success %}form was just submitted{% endif %}
Pass a string to getPost()
6
votes
Access POST data to conditionally display form
If you just want to test if something is in POST, and don't care what it is, then this should work:
{% set success = craft.request.getPost() | length %}
{% if success %}
form was just submitted
{...
4
votes
Accepted
Compose URL POST parameters to filter entries by category?
I'd split the parameter string into an array and then loop through the categories and use a conditional to check if the value already exists in the parameter. It's not so easy to describe in detail, ...
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 ...
3
votes
Multiple category output in auto generated entry title
I think you could also use Twig's join filter instead of the for loop:
{{ object.category | join('/') }}
2
votes
Accepted
Multiple category output in auto generated entry title
When you use the single brace tag syntax within your URL Format field:
{category.first().title}
that’s actually a shortcut for this:
{{ object.category.first().title }}
So, object is the actual ...
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
Registration email link not being sent
If you're using phpmail or sendmail under Settings->Email in the control panel, they are notoriously unreliable at delivering emails consistently.
Try using a proper SMTP relay or a transactional ...
2
votes
Accepted
Get _POST from Select element in Form
Form elements need to have a name attribute.
<select name="submission" id="submission">
<option value="view">View</option>
<option value="submit">Submit</option>
</...
2
votes
Accepted
How to create entry from external app webhook?
You would need to set this up using a plugin. The plugin would, at a minimum, contain a controller, with an 'action' method designed to handle the url request and generate an entry; using 'post' or '...
2
votes
Pixel & Tonic's Contact Form Plugin - POST submissions to Zapier Webhook URL?
By putting the webhook URL in the action field, you're completely bypassing the Contact Form's processing of the POST request and getting back a JSON response from Zapier.
I believe the correct way ...
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
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
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.
...
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" ...
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
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
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("");
...
1
vote
Accepted
Posting an entry without using a form?
If you're looking for an "audit trail" of pages a user has visited, then a plugin will be the way to go.
You'd want to track a user by something like their PHP session ID. And for every request grab ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
post × 26form × 6
templating × 3
csrf × 3
request × 3
craft3 × 2
plugin-development × 2
entries × 2
assets × 2
plugins × 2
users × 2
entry × 2
plugin-contactform × 2
php × 1
redactor × 1
url × 1
error-message × 1
image × 1
emails × 1
ajax × 1
login × 1
controller × 1
javascript × 1
mysql × 1
routing × 1