Answers.Body: <p>When saving an entry field type as part of your plug-in it needs to be an array of IDs in order to work correctly. This can either be handled via a plug-in or in the form by passing the value as an array to that field handle.</p>
  
  <p>Plug-in:</p>
  
  <pre class="lang-php prettyprint-override"><code>$user-&gt;setContentFromPost(array(
      'entryField' =&gt; array(10)
  ));
  $success = craft()-&gt;users-&gt;saveUser($user);
  </code></pre>
  
  <p>Front-end form:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;input type="hidden" name="fields[relatedEntry][]" value="{{entry.id}}"&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-07T13:02:53.520Z
Answers.Text: Ah my bad, i dont think i have explained it well. The channel entries already exist, when a user updates their profile from a front end form i have created, they get to choose a channel entry from a drop down list. Problem i am having is that by selecting a channel entry and saving, the related field in their profile is remaining empty. Basically, what do i do to the form field in the user update form, for craft to relate the user to the chosen channel entry.
Answers.UserDisplayName: BillyMedia
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-07T13:04:24.953Z
Answers.Text: So you want them to be able to choose a specific entry to be related to their profile?
Answers.UserDisplayName: mcclaskiem
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-07T13:04:52.500Z
Answers.Text: That is correct.
Answers.UserDisplayName: BillyMedia
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-07T13:06:30.807Z
Answers.Text: My dropdown list of channel entries consists of the entry.id for the value, and entry.title for the label. and the field has a name of fields[myrelatedfield].
Answers.UserDisplayName: BillyMedia
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-07T13:08:56.713Z
Answers.Text: updated answer, working on a code example now!
Answers.UserDisplayName: mcclaskiem
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-07T13:09:30.667Z
Answers.Text: ah, so you cant relate a user to a channel entry from the form? as in craft doesnt handle this out the box? If i understand you correctly. i am already doing this so admins can view the channel entry to see a list of users.
Answers.UserDisplayName: BillyMedia
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-07T13:12:02.577Z
Answers.Text: see updated answer, that should get you what you need
Answers.UserDisplayName: mcclaskiem
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-07T12:51:09.030Z
Answers.LastActivityDate: 2016-04-07T14:05:03.793Z
Answers.LastEditDate: 2016-04-07T14:05:03.793Z
Answers.UserDisplayName: mcclaskiem
Body: <p>I have a channel which has a relate to user field, how do I setup the front-end form which is a user details update form so they can select a channel entry from a drop down and when saved, have it relate that user to the channel entry.</p>
  
Tags: <form><user-profile><current-user>
Title: How do I relate a user to a channel entry from a form?
ThreadText: # How do I relate a user to a channel entry from a form?
  
  (Asked by: username_0 on 2016-04-07)
  
  I have a channel which has a relate to user field, how do I setup the front-end form which is a user details update form so they can select a channel entry from a drop down and when saved, have it relate that user to the channel entry.
  
  **Tags:** form, user-profile, current-user
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-04-07. Score: 4 | Accepted answer
  
  When saving an entry field type as part of your plug-in it needs to be an array of IDs in order to work correctly. This can either be handled via a plug-in or in the form by passing the value as an array to that field handle.
  
  Plug-in:
  
  ```php
  $user->setContentFromPost(array(
      'entryField' => array(10)
  ));
  $success = craft()->users->saveUser($user);
  
  ```
  
  Front-end form:
  
  ```html
  <input type="hidden" name="fields[relatedEntry][]" value="{{entry.id}}">
  
  ```
  
  > **Comments:**
  > **username_0**: Ah my bad, i dont think i have explained it well. The channel entries already exist, when a user updates their profile from a front end form i have created, they get to choose a channel entry from a drop down list. Problem i am having is that by selecting a channel entry and saving, the related field in their profile is remaining empty. Basically, what do i do to the form field in the user update form, for craft to relate the user to the chosen channel entry.  
  > **username_1**: So you want them to be able to choose a specific entry to be related to their profile?  
  > **username_0**: That is correct.  
  > **username_0**: My dropdown list of channel entries consists of the entry.id for the value, and entry.title for the label. and the field has a name of fields[myrelatedfield].  
  > **username_1**: updated answer, working on a code example now!  
  > **username_0**: ah, so you cant relate a user to a channel entry from the form? as in craft doesnt handle this out the box? If i understand you correctly. i am already doing this so admins can view the channel entry to see a list of users.  
  > **username_1**: see updated answer, that should get you what you need  
  
  ---
  
  