Skip to main content
8 votes
Accepted

What are the different scenarios to plan for when using $allowAnonymous in a controller?

Here are the new constants that Craft 3.2 introduced: const ALLOW_ANONYMOUS_NEVER = 0; const ALLOW_ANONYMOUS_LIVE = 1; const ALLOW_ANONYMOUS_OFFLINE = 2; By default every controller will have the ...
Ben Croker's user avatar
  • 7,536
7 votes
Accepted

Unsure whether to use Sprout Forms or code forms regularly

Sprout Forms offers you a lot of the same functionality as standard Craft Entries. Both Sprout Forms and Entries allow you to create front-end forms that allow users to submit data to the database. ...
Ben Parizek's user avatar
  • 13.5k
6 votes

Front end edit: entry doesn’t get saved

The possible reason for no errors being shown is that you re-define your entry variable before displaying the errors. Make sure you have {% if entry is not defined %} {% set entry = craft.entries....
Yuri Salimovskiy's user avatar
6 votes
Accepted

Update form entry using the Guest Entries plugin

In Craft 3 / Guest Entries 2, you could pull this off without hacking Guest Entries by writing a module that listens to the beforeSaveEntry event, and sets the id on the entry. use Craft; use craft\...
Brandon Kelly's user avatar
6 votes
Accepted

How does Craft automatically wrap `fields[]` around name attributes?

I believe its the namespace twig template function - and fields typically use the default namespace as fields. This is defined under templates/_includes/fields.html Looking at that file (below), you'...
crawf's user avatar
  • 3,562
6 votes

Looking for an advanced form plugin for Craft CMS

To answer your questions in regards to how they will fit with Freeform... If what you mean by pre-populating fields with existing data is being able to fill fields with data from other elements, ...
Solspace's user avatar
  • 1,410
4 votes

What is the best way to append CSRF token without using a form?

This is the syntax for Craft 3: <script type="text/javascript"> window.csrfTokenName = "{{ craft.app.config.general.csrfTokenName }}"; window.csrfTokenValue = "{{ craft.app.request....
Ryan's user avatar
  • 1,952
4 votes

Allow user to change or delete their photo for their profile from the front end

FWIW, Niall, I've always just created an additional Profile field for people's images. The weird "not really an asset" aspect of the profile pictures is gone in Craft 3, but I found enough annoyances ...
andrew.welch's user avatar
  • 11.6k
4 votes

How do I enable redactor rich text editor in a front-end form?

For Craft 3 you can use: {%- do view.registerJsFile(view.getAssetManager().getPublishedUrl('@vendor/craftcms/redactor/lib/redactor/redactor.js')) -%} {%- do view.registerCssFile(view.getAssetManager()...
77120's user avatar
  • 141
4 votes
Accepted

How do I relate a user to a channel entry from a form?

When saving an entry field type as part of your plug-in it needs to be an array of IDs in order to work correctly. This can either be handled via a plug-in or in the form by passing the value as an ...
mcclaskiem's user avatar
4 votes
Accepted

get post data after submitting User Profile Form for success message

Not possible – any input values added to your profile editing form (such as test in your case) will be included in the POST request to the users/saveUser controller action, but they won't actually be ...
Mats Mikkel Rummelhoff's user avatar
4 votes

Change entry status on front end

You need to include a hidden field with the value of 0 before the checkbox to ensure that the value is included in the form data if the checkbox is unchecked. See the docs on templating for checkbox ...
Steve Rowling's user avatar
4 votes
Accepted

Editing entry in front-end

I managed to find a solution, using hidden input fields :) Thank you for all the help :) Edit: Ended up solving this by using tables and saving the username and ID in that. Used a plugin called Super ...
Filip Iversen's user avatar
4 votes

Update form entry using the Guest Entries plugin

I've figured it out Go to GuestEntriesController.php and add this line of code on the 182nd line $entry->id = craft()->request->getPost('entryId'); Then add an hidden input field with the ...
Branko's user avatar
  • 497
4 votes
Accepted

Front End Asset Management - Upload New Photos without Deleting/Overriding Existing

You're right that your template needs some adjustments. Whenever you're saving an Assets field, you need to have all of the Asset id's not just the new ones. You're looking for something like {% if ...
Andris Sevcenko's user avatar
4 votes
Accepted

Frontend form with relation to an entry

After research with lots of trail & error I found the solution. I just had to add [] to my hidden field to establish the relation: <input type="hidden" name="fields[assetId][]" value="1478" id=...
Marco's user avatar
  • 213
4 votes

Generate pdf with form submission data

Note: I've never used amforms nor mPDF, so I'm on a bit thin ice with this answer – hopefully it'll prove semi-useful, though. How do I add the mPDF library to Craft? To include any third-party ...
Mats Mikkel Rummelhoff's user avatar
4 votes

How to call Controller in Module?

You need to include your module handle to the route module-handle/site/say You also should use the correct namespace instead of app/controllers I suggest you to read the documentation You can as ...
Robin Schambach's user avatar
4 votes
Accepted

How I can capture previous and current URL to a hidden form field

In the context of Craft 3, <input type="hidden" name="referrerUrl" value="{{ craft.app.request.getReferrer()" /> <input type="hidden" name="currentUrl" value="{{ craft.app.request....
Brad Bell's user avatar
  • 67.5k
4 votes
Accepted

How to re-populate form with old values when submitted from a controller?

There are several things you may need to dig into more to get the full picture here but here's a general idea of how you can approach this in Craft 3. Flash errors are useful to display a message in ...
Ben Parizek's user avatar
  • 13.5k
4 votes
Accepted

How to build contact form from scratch (no plugin)

Here’s an example of how you can do exactly that using only the CraftQL plugin: Using Vue.js + GraphQL to make Practical Magic You can also do it with a frontend Entry form without any any plugins at ...
andrew.welch's user avatar
  • 11.6k
4 votes
Accepted

Is there a way for a user to assign another user to a group on the frontend?

Assuming you're using the core users/save-user action to edit users (as per the official User Profile form example) you can add a form input named groups to save group assignments from the frontend ...
Mats Mikkel Rummelhoff's user avatar
4 votes
Accepted

Contact Form is not working anymore since upgrading from Craft 3 to 4

welcome to the CraftCMS StackExchange 👋 I dug around on the craftcms/contact-form repo and found an open issue for the same error you're describing. Basically, (as things currently stand) you need to ...
Jalen Davenport's user avatar
  • 3,045
3 votes
Accepted

Edit user's first and last name

A User's first and last name fields don't need the fields[] prefix as they aren't custom fields added to the user field group. So using the following should work: <label for="voornaam">{{"...
Luke Pearce's user avatar
  • 3,863
3 votes
Accepted

Wordpress-like Subscription

I would consider this carefully from a subscriber's perspective. i.e. If I received an email every time something was published, I may consider unsubscribing very quickly. An alternative which I've ...
Matt P's user avatar
  • 1,548
3 votes
Accepted

P/T ContactForm Retrieving Custom fields Value after submitting form

I just came across this question, for the sake of up to date info for others, it is now possible to do this with the latest release(1.7) of the ContactForm plugin from Pixel & Tonic: https://...
Jacob's user avatar
  • 282
3 votes
Accepted

How do I prevent empty table rows from being created when a front end form is submitted?

I figured out a solution. When I looked in the database I could see {"col1":"","col2":""} in the content even though the user didn't enter any content in the front end text form field. I couldn't ...
Lori's user avatar
  • 866
3 votes

Editing entry in front-end

Looks like you want to implement a feature to vote for entries. Have a look at these plugins, they make this really easy for you. https://www.doublesecretagency.com/plugins/upvote https://github.com/...
carlcs's user avatar
  • 36.3k
3 votes

Form Plugin for Craft CMS

You can find most plugins for Craft here: https://straightupcraft.com/craft-plugins There's a few different form plugins to choose from, not sure if all of them will have what you're looking for. I'...
zackspear's user avatar
  • 545
3 votes
Accepted

A&M forms on submit internal server error

If you want to upload assets with your form, you will need to include enctype="multipart/form-data" in your form tag: <form method="post" accept-charset="UTF-8" enctype="multipart/form-data" ...
Wolfram Gehring's user avatar

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