Set value for custom field

05/07/2018


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

$entity->get('field_myfield')->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->set('field_myfield', ['data' => 'some data'], 'value' => 'some value');

This doesn’t work.

قالب وردپرس