8

File fields are used for uploading new images. To delete all the Assets for a field, submit a hidden field with no values. <input type="hidden" name="fields[assetsField]" value="" /> If, on the other hand, you want to retain some of them, then make that hidden field an array with the values you'd like to keep. Like this <input type="hidden" name="...


8

A little bit late but here it is. Go to https://pluginfactory.io/ and create a plugin, you need at least 1 Controller but you can leave the Name value blank to create a controller with the same Name as your PluginHandle. So if you choose "Experiment" as your Pluginhandle your controller will be ExperimentController Click on "Build my Plugin" and save the ...


5

Craft 3 uses snake-case paths instead of camelCase paths Your action parameter must be entries/save-entry Its all stated in the docs Edit: generally a good idea is to inspect the html in your cp form and copy it to your frontend. You'll be able to solve 90% of your issues that way


4

The parameter is called siteId <input type="hidden" name="siteId" value="{{ currentSite.id }}">


3

You need to pass your custom fields in a fields array, try: {{ input('text', 'fields[headline]', entry.headline, { required: true, class: entry.hasErrors('headline') ? 'text error' : 'text' }) }} See example here - https://craftcms.com/knowledge-base/entry-form


3

The trick, as it were, is to define the Matrix field in your form as an array. First, the Matrix entry field itself: <input type="hidden" name="fields[traveller][new1][type]" value="travellerDetails"> <input type="hidden" name="fields[traveller][new1][enabled]" value="1"> Then, for each field within the Matrix block: <input type="text" ...


3

Of course it clears all the existing matrix elements if you update an entry. For craft it's like you delete the existing matrix blocks and create a new one. In order to keep all of them you have to send them in the form or create a custom controller to do it. You can insert all current matrix blocks in hidden fields, so users won't see them but craft will ...


3

You just need to specify a hidden input with the typeId set correctly. i.e. <input type="hidden" name="typeId" value="{{ entry.typeId }}">


2

You can write a simple plugin that listens for the onSaveEntry event. When that event fires, you plugin could check the $isNewEntry param to make sure it's a new entry being saved and also check the entry's section to make sure it's the front-end section you're expecting and might as well check craft()->request->isSiteRequest() to make sure it's a ...


2

I think I found the answer, correct me if I'm wrong but you can access your post data in your plugin with: craft()->request->getPost('fields') Not sure if this is the recommended way.


2

I don't have any example code to offer, as I've never had a need to do something like this, but the way I see it there are 2 basic approaches: Use Javascript on form submission to first create the tags with an AJAX call. Use a custom plugin controller to handle the tag creation before passing the call on to it to the entry controller. Either way I would ...


2

First of all generally it's a really good idea to check how Pixel and Tonic has handled all the things. I know many people tend to dislike this hint but it's the best thing you can do. The developers are really good, they make good and useful comments and - at least for Craft 3 - they take care of the PHP Doc (in Craft 2 too but not as well) When I run ...


2

Thanks for the assist. Just updated my Craft and all sorted.


2

You can use the instance of test (docs) {% if field is instance of ('craft\\fields\\PlainText') %} or use className (docs). {% if field.className == 'craft\\fields\\PlainText' %} In full: {% for tab in entry.fieldLayout.tabs %} <div class="form__row"> <h3>{{ tab.name }}</h3> </div> {% for field in tab....


1

Thanks Oli! I got this working after making two changes: Add hidden field for declaring Matrix block type {# For the new activity block #} {{ hiddenInput('fields[planningSchedule][sortOrder][]', 'new:1') }} {{ hiddenInput('fields[planningSchedule][blocks][new:1][type]', 'activity') }} My Time field's select option values were not formatted correctly. Need ...


1

You seem to be missing the block type: <input type="hidden" name="fields[planningSchedule][blocks][new:1][type]" value="text" /> and change the value to your block type (handle).


1

This is a great learning resource. Worth the investment, IMO, if you're building a lot of sites with Craft CMS. https://craftquest.io/lessons/switching-from-craft-local-assets-volume-to-s3


1

Thanks to everyone for their input, but I solved the problem using an alternative fieldtype. I'd have rather stuck with a native fieldtype, but deadlines are an unforgiving mistress.


1

Do you have something like {{ entry.traveller.one().travellerDetails.one().travellerTitle }}? Even if you limit the number of matrixes to 1, Craft still creates an array, so you need to include .one() after the matrix field name and matrix block name. If you use a for loop, you wouldn't need the .one().


1

Yes, you can do this without a plugin. You just need a frontend entry form, ala https://docs.craftcms.com/v3/dev/examples/entry-form.html Now if you want them to be able to add/remove fields, then instead of hardcoding the fields, you'll need to iterate through the fields that are in a particular field layout. A way to do that is discussed here: How to ...


1

Personally I don't have any experience with Free Form but have been using Sprout forms for quite some time now. In Sprout forms your client can create entire forms or just add a couple of fields however you like it. The support on Sprout forms is decent aswell. Plus sprout forms got email notifications aswell which might be interesting for your client.


1

I'd caution against trying to adapt the ElementAPI plugin for this purpose, as it was designed to be read-only—it's basically a wrapper around Craft's ElementQuery interface, which does not handle write operations. In lieu of that, you might take a look at the CraftQL plugin, by Mark Huot. It supports sophisticated queries (reading), as well as mutations (...


1

Could this be a reserved word? Generally I access fields using entry.registeredOccurances is there a reason you are using fields[registeredOccurances] and entry[dateFieldHandle]?


1

In the end I didn't get this working with replacing the new_0 in the fields array of the ajax content. I opted instead to limit adding new people to one at a time by having the new person button fade out when clicked and a message appearing stating: You must save your entry to add more staff In the end this forces the store manager to save their work ...


1

You can get the number of rows you already have from the DOM, then use that to determine how many you'll have after you add a new one. $('#addPerson').click(function(e){ e.preventDefault(); console.log('clicked addPerson'); var newPerson = "<div class='newperson'></div>"; $('.newBlock').append(newPerson); $('.newBlock .newperson:last-...


1

I believe you're looking for entryRevisions/publishDraft: <input type="hidden" name="action" value="entryRevisions/publishDraft"> You can see the specific inputs it is looking for here: https://github.com/craftcms/cms/tree/master-v2/src/controllers/EntryRevisionsController.php#L188


1

Right, the issues was that there was a validation error on a field, but the form didn't reload and display those errors, it just went to a 404 page.


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