Set EntryModel data on an element I am trying to update the value of an Entries field on an EntryModel, however I am having a lot of trouble getting it to update correctly.

I've tried allocating both an entire EntryModel and its id but neither seems to set the value, e.g.

$comment = new EntryModel();
$comment-&gt;sectionId = $commentSectionId;

$comment-&gt;setContent(array(
    'createdBy' =&gt; $user // or
    'createdBy' =&gt; $user-&gt;id
));

craft()-&gt;entries-&gt;saveEntry($comment);


Where $user is a valid EntryModel.

The comment saves fine, the createdBy field just has no value. I guess I am using the wrong data from $user but I have having a very hard time finding any thorough documentation around setting different kinds of EntryModel data.

This is the entire bit of code I have, if it helps:

class Bugr_CommentService extends BaseApplicationComponent
{

    public function post(EntryModel $user, EntryModel $ticket, $body)
    {
        $comment = new EntryModel();
        $comment-&gt;sectionId = craft()-&gt;sections-&gt;getSectionByHandle('comments')-&gt;id;

        $comment-&gt;setContent(array(
            'createdBy' =&gt; $user,
            'ticket' =&gt; $ticket,
            'body' =&gt; $body
        ));

        return craft()-&gt;entries-&gt;saveEntry($comment);
    }

}
To assign a related Element (i.e. related User, Category, Entry, Tag, Asset) the value should be set to an array of element ids (even if there is only one element).

public function post(UserModel $user, EntryModel $ticket, $body)
{
    $comment = new EntryModel();
    $comment-&gt;sectionId = craft()-&gt;sections-&gt;getSectionByHandle('comments')-&gt;id;

    $comment-&gt;setContent(array(
        'createdBy' =&gt; array($user-&gt;id),
        'ticket'    =&gt; array($ticket-&gt;id),
        'body'      =&gt; $body
    ));

    return craft()-&gt;entries-&gt;saveEntry($comment);
}