Hot answers tagged

13 votes
Accepted

Is it possible to change a user's password in the front-end?

It is! To do so, they will have to be logged in and input their old password. They need the old password to change their email or update a password. Here's an example: {% macro errorList(errors) %} ...
  • 1,828
12 votes

Display list of countries in form using a dropdown

This is not the answer you were looking for, but if you decide to just go with a normal drop-down, then you can paste the following into the dropdown field in the database. This would go in the ...
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
11 votes

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

It’s technically possible to include Craft’s copy of Redactor on the front end: {% includeJsResource "lib/redactor/redactor.js" %} {% includeCssResource "lib/redactor/redactor.css" %} <textarea ...
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.7k
8 votes

Forms are triggering CSRF Protection. Why would CSRF Protection trigger false positives?

We got this sorted before I finished my Stack Exchange question so I figured I'd share if anyone else runs into similar behavior. After some troubleshooting, we learned that the issue here was that ...
  • 13.3k
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 ...
  • 6,561
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
Accepted

How do I extend another plugin?

I believe what you asking about are Hooks and Events. Craft has several of them listed in the Hooks Reference and Events Reference. And Craft also allows us to add Hooks and Events in our plugins, ...
  • 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

Edit a table field type from the front end

Each input name needs to have the following format: fields[FieldHandle][RowId][ColId] It doesn’t matter what you set RowId to, as long as it’s the same for all of the columns in that row. (Table ...
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,457
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

Category as select dropdown box

So looks like I was just missing the extra [] in the name. fields[borough][] Since categories are arrays the name also needed to be an array!
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

where can I find manual for craft forms

At this time, there is no manual for it. It's an incredibly useful chunk of code, but it's buried pretty deep in the system. I think the belief is that "if you're capable of finding it, you're ...
  • 23.7k
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
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.7k
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,332
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.2k
4 votes
Accepted

How do I hide a login form if user is logged in?

The Twig variable currentUser contains information about the currently logged in user, and will be null if no user is currently logged in. {% if not currentUser %} <!-- Your login form --> ...
  • 23.7k
4 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/...
  • 346
4 votes
Accepted

How do I save a front-end form as a specific Entry Type?

This has been solved via a support ticket, which I'm posting here for others etc. The first time you load the template, the URI is mapping to your "Get A Quote" entry, which gets assigned to the ...
  • 3,225
4 votes

How do I enable editing of entries with a front-end form?

Add another hidden input field "entryId" to your form. There's nice example code in the Docs: You can modify the form to save existing entries by adding an “entryId” hidden input to the ...
  • 36k
4 votes

Display list of countries in form using a dropdown

Unfortunately the drop down options in Territories Dropdown Plugin are not automatically available in templates. It need to be accessed through a field on an element. You're currently trying to access ...

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