title: How to programmatically select list (text) field in Drupal 8?
body: <p>I have successfully created node programmatically using Drupal 8 Node::create and be able to select list (integer) field correctly as following, but list (text) field is not getting selected with the same process. Any help appreciated.</p>
  
  <h1>(Manage Fields)</h1>
  
  <pre><code>LABEL   MACHINE NAME    FIELD TYPE
  ===========================
  
      Expires (in Days)   field_expires_in_days_  List (integer) -&gt; NOT WORKING
      Item Type   field_item_type List (text) - Working
  </code></pre>
  
  <h1>Allowed value list for 'field_expires_in_days_</h1>
  
  <pre><code>30|30
  60|60
  90|90
  </code></pre>
  
  <h1>Allowed value list for 'field_item_type'</h1>
  
  <pre><code>tipsheet|Tip Sheet
  fyi|FYI
  video|Video
  </code></pre>
  
  <h1>(Controller)</h1>
  
  <pre><code>$newListItem = array(); //prepare new item
  $newListItem["title"] = "Title 111";
  $newListItem["summary"] = "Some description";
  $newListItem["itemType"] = "tipsheet";
  $newListItem["expiresInDays"] = "30";
  
  $node = Node::create([
  'type' =&gt; 'custom_content_type',
  'status' =&gt; 1,
  'title' =&gt; $listItem['title'],
  'body' =&gt; $listItem['summary'],
  'field_item_type ' =&gt; $listItem['itemType'],
  'field_expires_in_days_' =&gt; $listItem['expiresInDays'],
  ]);
  $node-&gt;save();
  </code></pre>
  
  <p><a href="https://www.drupal.org/node/2650648" rel="nofollow">https://www.drupal.org/node/2650648</a></p>