Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Hot answers tagged

19 votes
Accepted

How do you create a front-end form for users to submit content?

If the users are authenticated and have permission to post to the event section, you would use an entry form to accept posts from the front end. Example from the above linked page... <form method=...
user avatar
  • 3,901
18 votes
Accepted

Does anyone have a working example of frontend form with multiple file upload, drag & drop etc?

OK, figured it out (or at least it works, so correct me if a better way is available): This method assumes logged in frontend users, not sure if it's possible for guests, have not tested that. Might ...
user avatar
  • 6,288
16 votes
Accepted

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

Before you can allow a user to manage their profile photo in your front-end profile edit form, be sure to update your form tag with the enctype="multipart/form-data" parameter: <form method="post" ...
user avatar
  • 13.2k
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) %} ...
user avatar
  • 1,818
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 ...
user avatar
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 :) ...
user avatar
  • 4,509
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 ...
user avatar
10 votes

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

If you want a user to be able to upload a profile photo from the front-end, the you should be able to add enctype="multipart/form-data" to your form that saves your user and have a file input called '...
user avatar
  • 66.4k
9 votes
Accepted

How do you delete assets from a frontend form?

You can create a POST request via Ajax to the assets/deleteFile (Craft 2) / assets/delete-asset (Craft 3) controller action: Craft 2: $('#delete-file').click(function() { var data = { ...
user avatar
9 votes
Accepted

Can I accept file uploads using the Craft Guest Entries plugin?

I don't see why you couldn't. That is unless the plugin needs to handle file uploads as opposed to the Entry Model. Take a look at Uploading Files from a Form. You need to make sure your form tag has ...
user avatar
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 ...
user avatar
  • 13.2k
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' ...
user avatar
  • 66.4k
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 ...
user avatar
  • 13.2k
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 ...
user avatar
  • 6,156
7 votes
Accepted

Email Notification When Post Submitted

Currently there isn't a native way to do this, but you could write a plugin which would work like this: Wait for an event like: content.onSaveContent or entries.onSaveEntry Get all users from a ...
user avatar
  • 8,316
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. ...
user avatar
  • 13.2k
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 ...
user avatar
6 votes
Accepted

How do I setup a password administration workflow using setPasswordPath and a forgot password page?

The form that lives at setPasswordPath assumes that the user arrived there by clicking on the link in the validation email that was sent to the provided email address. That link includes a code=...
user avatar
  • 66.4k
6 votes
Accepted

How do you delete entries from a frontend form?

It's going to be virtually identical to this answer, with the exception that you're posting to the 'entries/deleteEntry' controller action instead of 'assets/deleteFile' and you're posting the '...
user avatar
  • 66.4k
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, ...
user avatar
  • 13.2k
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 ...
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\...
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'...
user avatar
  • 3,392
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, ...
user avatar
  • 1,390
5 votes
Accepted

Can you set the redirect path for system forgot password form?

You can. You have to build some front end forms: Forgot Password Form (http://buildwithcraft.com/docs/templating/forgot-password-form) Set Password Form (http://buildwithcraft.com/docs/templating/set-...
user avatar
  • 1,818
5 votes
Accepted

Where do I begin troubleshooting a Form in Craft that is redirecting to /login on iPad and iPhone?

Just an idea, but are you Allowing Anonymous Access to Actions? Maybe you are logged in on your Desktop, but not on your iPhone. Example: protected $allowAnonymous = true;
user avatar
  • 8,316
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!
user avatar
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....
user avatar
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 ...
user avatar
  • 23.6k
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 ...
user avatar

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