Hot answers tagged

11 votes

User registration: How do implement "Confirm password" and "Confirm email"?

If anyone is interested in confirming passwords still, I have wrote a plugin which does just this, it doesn't rely on it's own controller either so there is no bypassing of Crafts own workings :) ...
  • 4,519
9 votes

Front end edit: entry doesn’t get saved

I've run into this situation in various scenarios as well where a front-end entry form fails to save anything and just seems to be reloading the page. Almost always it has had to do with overlooking a ...
  • 13.3k
9 votes
Accepted

Populating tables and matrix fields using GuestEntries

See here for example front-end HTML code for all of Craft's default field types: https://straightupcraft.com/articles/craft-cms-field-guide-twig?view=input Matrix: {# You need to include the 'type' ...
  • 66.9k
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 ...
  • 7,071
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. ...
  • 13.3k
6 votes

Email Notification When Post Submitted

For those that are looking for a plugin that simply notifies users (without all the overhead), take a look at Brief. It's a super-light plugin that simply notifies users whenever a new entry is added ...
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\...
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'...
  • 3,507
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, ...
  • 1,390
5 votes
Accepted

Delete items from frontend with ajax

That looks perfect! Obviously this code doesn't prompt the user to confirm deletion, but that can easily be added. (Or perhaps you stripped that out of your example.) You are specifically doing two ...
  • 23.8k
5 votes
Accepted

How do you correctly handle errors using PT Contact Form when submitting via AJAX?

If you want the error messages to be displayed identical to P&T's template/macro default, this should do the trick: $(function(){ $('#ajax-form').submit( function(ev) { // Prevent ...
5 votes

_includes/forms documentation on field types

For anyone looking for more information, you can find all of the form macros for _includes/forms here: /craft/app/templates/_includes/forms.html and the child templates here: /craft/app/templates/...
  • 356
5 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....
5 votes
Accepted

Ajax front-end user registration form - not returning JSON

EDIT Craft 2.4 is now available, and the users/saveUser action will now return a JSON response for AJAX requests. The original answer is still valid for <2.4 builds: No, there's no way to ...
5 votes
Accepted

How to populate Category field form frontend form?

Couple things. First, I believe you need to add an extra set of brackets to the name attribute. The reason being that category fields (as well as all 'related' fieldTypes) store more than one element, ...
5 votes
Accepted

Get the ID of a new entry when it's saved

If you wanted to do this without having to write your own plugin, you can achieve this with a simple custom route and an extra parameter in your template. Your hidden fields could look like: <...
  • 4,519
5 votes
Accepted

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

You need to pass the token and name into javascript. Easiest is to just have a script tag somewhere. <script type="text/javascript"> window.csrfTokenName = "{{ craft.config.csrfTokenName }}"...
  • 1,342
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 ...
  • 11.3k
4 votes

Display list of countries in form using a dropdown

This doesn't really address the problem either, but for anyone looking for "States" data (to replicate what Douglas McDonald did), here it is: {"options":[{"label":"Alabama","value":"AL","default":""}...
  • 356
4 votes

How do I retain form input values after submitting error-ridden form containing matrix field inputs

As you've discovered, your Matrix Field behaves a bit differently than many other basic fields. The Matrix Field, is composed of several Matrix Blocks and, like Entries themselves, Matrix Blocks are ...
  • 13.3k
4 votes
Accepted

Is it possible to cache a faceted search form?

There're various ways of doing this. The simplest would be to just use the submitted slugs to generate a new cache key for each different search, like Jamie suggests. This is a very straightforward ...
  • 7,258
4 votes

Sprout Forms: Localized version of form with translated labels?

Currently, Sprout Forms (v1.1.0) is translatable, but we have not yet added support for Craft's localization feature. You can find a template of a translation file on our Github Account. We want to ...
  • 13.3k
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....
  • 1,942
4 votes

Sprout Form Not Saving Entries

Re-installing the Sprout Invisible Captcha plugin and including the following line before the closing tag got it working: {{ craft.sproutInvisibleCaptcha.protect() }}
4 votes
Accepted

Is it possible to POST to an action if the system is offline?

Completely untested, but something like this in your craft/config/general.php file should work: return array( 'isSystemOn' => (isset($_REQUEST['action']) && !$_REQUEST['action'] != '...
  • 66.9k
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 ...
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 ...
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 ...
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 ...
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 ...
  • 495

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