Answers.Body: <p>After research with lots of trail &amp; error I found the solution. I just had to add [] to my hidden field to establish the relation:</p>
  
  <pre><code>&lt;input type="hidden" name="fields[assetId][]" value="1478" id="hidden-assetID"&gt;
  </code></pre>
  
  <p>The leading hint was here: <a href="https://craftcms.stackexchange.com/questions/8536/setting-user-field-type-from-a-front-end-form">Setting User field type from a front end form</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-10T07:26:35.647Z
Answers.LastActivityDate: 2017-05-10T07:26:35.647Z
Answers.UserDisplayName: Marco
Body: <p>I have a field called "assetId" from Entry "A" with Field Type "Entries" and Source "B". How can I build a form so that a relation between these two entries will be established.</p>
  
  <p>In the craft backend I can add a new entry in Entry "A" and can use the Button "Add an entry" to select the suitable Entry from "B". This works fine. A record is written in the Table craft_relations.</p>
  
  <p>How can I build a user form in the frontend to get this. I tried following form with a hidden field "fields[assetId]" which is set to the id of the suitable content:</p>
  
  <pre><code>&lt;form method="post" accept-charset="UTF-8" enctype="multipart/form-data" class="send-form" id="send-form"&gt;
      &lt;input type="hidden" name="action" value="entries/saveEntry"/&gt;
      &lt;input type="hidden" name="sectionId" value="34"&gt;
      &lt;input type="hidden" name="enabled" value="1"&gt;
      &lt;input type="hidden" name="fields[assetId]" value="1478" id="hidden-assetID"&gt;
      [... some more fields ...]
       &lt;input class="btn-vote" type="submit" value="send"&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p>The entry is saved correctly, but without the assetId. There is no relation between targetId 1478 and the new entry in the Table craft_relations established. What am I doing wrong?</p>
  
Tags: <entries><relations><form><entry><entries-field>
Title: Frontend form with relation to an entry
ThreadText: # Frontend form with relation to an entry
  
  (Asked by: username_0 on 2017-05-09)
  
  I have a field called "assetId" from Entry "A" with Field Type "Entries" and Source "B". How can I build a form so that a relation between these two entries will be established.
  
  In the craft backend I can add a new entry in Entry "A" and can use the Button "Add an entry" to select the suitable Entry from "B". This works fine. A record is written in the Table craft\_relations.
  
  How can I build a user form in the frontend to get this. I tried following form with a hidden field "fields[assetId]" which is set to the id of the suitable content:
  
  ```
  <form method="post" accept-charset="UTF-8" enctype="multipart/form-data" class="send-form" id="send-form">
      <input type="hidden" name="action" value="entries/saveEntry"/>
      <input type="hidden" name="sectionId" value="34">
      <input type="hidden" name="enabled" value="1">
      <input type="hidden" name="fields[assetId]" value="1478" id="hidden-assetID">
      [... some more fields ...]
       <input class="btn-vote" type="submit" value="send">
  
  </form>
  
  ```
  
  The entry is saved correctly, but without the assetId. There is no relation between targetId 1478 and the new entry in the Table craft\_relations established. What am I doing wrong?
  
  **Tags:** entries, relations, form, entry, entries-field
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2017-05-10. Score: 4 | Accepted answer
  
  After research with lots of trail & error I found the solution. I just had to add [] to my hidden field to establish the relation:
  
  ```
  <input type="hidden" name="fields[assetId][]" value="1478" id="hidden-assetID">
  
  ```
  
  The leading hint was here: [Setting User field type from a front end form](https://craftcms.stackexchange.com/questions/8536/setting-user-field-type-from-a-front-end-form)
  
  
  ---
  
  