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

<pre><code>&lt;select multiple name="fields[fieldHandle][]"&gt;
    &lt;option value="13"&gt;Tag Name One&lt;/option&gt;
    &lt;option value="42"&gt;Tag Name Two&lt;/option&gt;
    &lt;option value="144"&gt;Tag Name Three&lt;/option&gt;
&lt;/select&gt;
</code></pre>

<p>Replace <code>fieldHandle</code> with the actual handle of your Tags field and <code>13</code>, <code>42</code> and <code>144</code> with the actual Tag IDs.</p>

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

CC BY-SA 3.0
2017-12-11T22:16:32.587Z
2017-12-11T22:16:32.587Z
Brad Bell
<p>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.</p>

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

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

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

CC BY-SA 4.0
2020-05-04T21:29:05.893Z
2020-05-04T21:29:05.893Z
Adrian
<p>I have a project that the user choose a tag (tags are already created) and save the information.</p>

<p>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.</p>

<p>I try <a href="http://buildwithcraft.com/docs/templating/entry-form" rel="nofollow noreferrer">entry form</a>.</p>

<entry><tags><frontend-form>
Save an entry with tags
# Save an entry with tags

(Asked by: username_0 on 2017-12-11)

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](http://buildwithcraft.com/docs/templating/entry-form).

**Tags:** entry, tags, frontend-form


---

## 2 answers

### Answer by username_1 on 2017-12-11. Score: 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:

    Tag Name One
    Tag Name Two
    Tag Name Three


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


---

### Answer by username_2 on 2020-05-04. Score: 1

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 %}

    {% for tagOption in craft.tags.group('myTagGroup').all() %}
        {{tagOption.title}}
    {% endfor %}


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


---

