Set value for custom field I created a custom field but I don't know how to set a value.
I can read values with 

$entity-&gt;get('field_myfield')-&gt;getValue()[0]['data']


The field consists of several elements: value, data, api_key

I'm loading the entity and would like to set the values of the field programatically, I tried:

$entity-&gt;set('field_myfield', ['data' =&gt; 'some data'], 'value' =&gt; 'some value');


This doesn't work.
You don't need to worry as the entity API should take care of the specific structure and just set it via:

$entity-&gt;set('field_myfield', 'some value');
$entity-&gt;save();