I'm creating a new user using $user->setContentFromPost(). It all works fine except I can't attach an entry to an Entries field.

$user = new UserModel();
$user->username         = $email;
$user->email            = $email;
$user->unverifiedEmail  = $email;

  'companyName' => $admin->companyName, 
  'companyId' => $admin->companyId, 
  'partnerManager[]' => $admin->partnerManager[0]->id

This will create user but the partnerManager Entries field will be empty. I've tried a few different syntax variations, but none of them seem to work:

'fields[partnerManager][]' => $admin->partnerManager[0]->id
'partnerManager' => $admin->partnerManager[0]->id
'partnerManager[0]' => $admin->partnerManager[0]->id

How to fill this field?

1 Answer 1


Relationships are always added as arrays of IDs, even if you are only relating a single element:

    'companyName' => $admin->companyName, 
    'companyId' => $admin->companyId, 
    'partnerManager' => array($admin->partnerManager[0]->id)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.