How can I programmatically set the value of an Entries field type? I need to set programmatically the value of an Entries field type when I'm going to create a new entry from the admin form, after the form loads I'm searching for the entry I need to set in the Entries field, so I'm making something like setAttribute('companyField', $companyEntry) but it didn't work.

I need to find a way to set/lookup that value in the Entries field type so the user can see it in the UI.
For relationship fields (Entries, Assets, Users, Tags, etc.) you need to pass in an array of element IDs.

Something like this should work.

$entry-&gt;setAttribute('companyField', array($companyEntry-&gt;id));