Hot answers tagged

19

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="post" action="" accept-charset="UTF-8"> <input type="hidden" name="action" value="entries/saveEntry"> <input type="hidden" name="redirect" ...


17

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 give permission errors. Let's say, we have a section message with id 2, containing an asset field called photos. This is the field in which we want to save all ...


16

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" enctype="multipart/form-data"> You can access a users profile photo using the currentUser global and fallback to a different image like so: {% if ...


13

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) %} {% if errors %} {% for error in errors %} <div class="error icon-cancel-circled">{{ error }}</div> {% endfor %} {...


11

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 :) https://github.com/alecritson/Craft-Password-Confirm All you need to do is add a passwordConfirm field to your existing form: <input type="password" name="...


11

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 craft_fields table, yourCountryField row, settings column. After editing the list the way you need it I would suggest removing all line-breaks using grep find/replace ...


10

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 'userPhoto'. <input type="file" name="userPhoto" id="image-upload" /> If you want to delete a user's existing profile photo, then add a hidden input ...


10

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 id="jobOverview" name="fields[jobOverview]"></textarea> {% includeJs "$('#jobOverview').redactor();" %} ... But it’s not recommended. Redactor’s API ...


9

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 = { fileId: 100 }; $.post('/actions/assets/deleteFile', data, function(response) { // ... }); }); Craft 3: $('#delete-file').click(function() { ...


9

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 enctype="multipart/form-data" and your file input has the name fields[fieldHandle]. If you are uploading multiple files, be sure to add and extra set of square ...


8

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 required field or some other small detail, as Douglas mentions in his comment. If all of your fields are not required, make sure you are still setting fields ...


8

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 some of our Forms were being cached by Craft's {% cache %} tag and others were not. CSRF Cookies are unique per user per session, so you don't want to cache ...


8

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' input to identify the matrix block type you are submitting #} <input type="hidden" name="fields[fieldHandle][new1][type]" value="contacts"> {# All of ...


7

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 specific usergroup using the ElementCriteriaModel. Use the EmailService to send a mail to each of them. . Quick-and-Dirty: public function init() { parent::...


7

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. Here are a few thoughts on why you would choose one over the other to manage content that requires front-end forms. None of these reasons are absolute, so take ...


6

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 to a Section. If anybody has a specific need for it, I'd be glad to add features. More information: Brief


6

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=somelongid querystring parameter in the URL that the form is looking for. If you're just loading that URL directly, then you'll get the "Variable 'code' does not ...


6

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 'entryId' and the 'locale' of the entry you want to delete, instead of 'fileId'. Note that this requires a logged in user with necessary delete entry permissions.


6

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, which other plugins can leverage. In the case of Sprout Forms, as of this post, we don't have any documented events yet, but there are a couple in there and we'...


6

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'll notice that if you don't provide a namespace variable to the include, it'll use fields. {% if element is not defined %}{% set element = null %}{% endif %} {%...


6

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, Freeform can do this. It allows you to populate fields with data from other Craft Elements or even common Predefined data included with Freeform such as States, ...


6

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 following property: protected $allowAnonymous = self::ALLOW_ANONYMOUS_NEVER; And you can override it in your controller in various ways: // Allow anonymous ...


5

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-password-form) Be aware of the config setting, setPasswordPath. It's also worth noting that a user account with control panel privileges will be redirected ...


5

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;


5

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

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.id(craft.request.segment(4)).first() %} {% endif %} and not just {% set entry = craft.entries.id(craft.request.segment(4)).first() %}


5

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 fields in the CP just get incrementing row IDs - 0, 1, 2, etc.) ColId, on the other hand, needs to be based on your actual column IDs. The only way to get those ...


5

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 capable of backwards-engineering it." I'd actually suggest looking to other parts of Craft (and other plugins) to gain a better understanding of some real-world ...


5

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 the form from actually submitting ev.preventDefault(); // Remove any existing error messages from previous attempts $(this).find( '....


5

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 things right here: Hitting deleteEntry directly. This ensures that Craft follows all of its necessary internal procedures to properly delete the entry (and ...


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