Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-11T22:16:32.587Z
Answers.LastActivityDate: 2017-12-11T22:16:32.587Z
Answers.UserDisplayName: Brad Bell
Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-04T21:29:05.893Z
Answers.LastActivityDate: 2020-05-04T21:29:05.893Z
Answers.UserDisplayName: Adrian
Body: <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>
  
Tags: <entry><tags><frontend-form>
Title: Save an entry with tags
ThreadText: # 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:
  
  ```
  <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>
  </select>
  
  ```
  
  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 %}
  <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 %}
  </select>
  
  ```
  
  This searches a pre-built array for a value matching the `id` of each of the loaded tags. Hope this helps someone else!
  
  
  ---
  
  