I have saved a node programmatically, in the following way:
$node_storage = \Drupal::entityManager()->getStorage('node');
foreach ($entity_ids as $id) {
$node = $node_storage->load($id);
if (!$node) {
continue;
}
$node->set('field_tags', $new_tid);
$node->save();
After saving the node I am trying to edit it and I am getting the follow error upon submit.
InvalidArgumentException: The state '' does not exist in workflow 'draft' in Drupal\workflows\Entity\Workflow->getState()
I believe that this means that my node has no state.
How could I set the node's state?