Set value of List field of a node with multiple values I'm attempting to programmatically generate nodes of a custom content type from a form plugin. For most fields I don't have any trouble at all. For example for the title field I can set the value like so.

$node-&gt;title-&gt;value = t('My title');
$node-&gt;save();


However there is also a list(text) field that allows for multiple values. And I'm not sure how to go about saving values of field with multiple values. I'm assuming if there was only one value allowed I could do it just like I set the title in the previous example, but how do I deal with it when the field is an array? As a test I performed a die statement of the field on a node that already had values in that field to take a look at what it looks like and this was generated:

Array ( [0] =&gt; Array ( [value] =&gt; test_3 ) [1] =&gt; Array ( [value] =&gt; test_4 ) ) 1


But I'm not sure what to do with that. How would I set the field value of a list field with multiple values allowed?
You can replace the complete content of a field by assigning an array:

$node-&gt;field_multivalue = [
  ['value' =&gt; '1'],
  ['value' =&gt; '2'],
  ['value' =&gt; '3'],
];


If you want add another value to the field you can use the field like a php array:

$node-&gt;field_multivalue[] = ['value' =&gt; '4'];


You can omit the main property of a field:

$node-&gt;field_multivalue[] = '5';


Now you have 5 values in the field.