I have a project that the user choose a tag (tags are already created) and save the information.

I try save a entry which has a tag field, all the stuff saves, but the tags don't. I try search information about that, but any where have a solution or the solution doesn't work.

I try entry form.

2 Answers 2


Hard to know without seeing some template code, but the syntax for saving existing tags on a front-end entry form looks like this:

<select multiple name="fields[fieldHandle][]">
    <option value="13">Tag Name One</option>
    <option value="42">Tag Name Two</option>
    <option value="144">Tag Name Three</option>

Replace fieldHandle with the actual handle of your Tags field and 13, 42 and 144 with the actual Tag IDs.

There's a great list of examples for what front-end inputs need to look like for Craft fields here you might find useful: https://straightupcraft.com/articles/craft-cms-field-guide-twig?view=input


Here's a version for a frontend form that grabs the tags in the specified group, displays a multiple select list and highlights any tags that are already selected for that entry.

Replace myTagField with the name of your tag field, and myTagGroup with the tag group name. Note that entry must be defined as well.

{% set field = craft.app.fields.getFieldByHandle('myTagField') %}
{% set  selectedTags = []  %}
{% for selectedTag in craft.tags.relatedTo(entry) %}
    {% set  selectedTags = selectedTags|merge([selectedTag.id])  %}
{% endfor %}
<select multiple id="{{field.handle}}" name="fields[{{field.handle}}][]">
    {% for tagOption in craft.tags.group('myTagGroup').all() %}
        <option value="{{ tagOption.id }}"{% if tagOption.id in selectedTags %}selected="selected"{%endif%}>{{tagOption.title}}</option>
    {% endfor %}

This searches a pre-built array for a value matching the id of each of the loaded tags. Hope this helps someone else!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.