Get node_type entity for default value in form I'm attempting to allow users to enter a number of node types in an entity reference field inside a custom config form. However I can't seem to supply it with a proper default value. My field in the form looks like this:

$config = $this-&gt;config('contentform.settings');
    $form['content_types'] = [
        '#type'          =&gt; 'entity_autocomplete',
        '#description'   =&gt; t('Choose what content types to map'),
        '#target_type'   =&gt; 'node_type',
        '#default_value' =&gt; $config-&gt;get('content_type'),
    ];


However $config->get('content_type') only supplies me with the label of the content type.

So I get the following error 


  InvalidArgumentException: The #default_value property has to be an
  entity object or an array of entity objects


I'm saving the value in the submit function like so:

    $content_type = $form_state-&gt;getValue('content_types');
    $this-&gt;config('contentform.settings')
         -&gt;set('content_type', $content_type)
         -&gt;save();


I've also tried $form_state->get('content_types') and $form_state->get('content_types')->entity; But those didn't work either.

How would I get the node_type entity or object instead of just the label? Or is there a way to load the node_type from just the name?
You can load a node_type entity by specifying the node type id

$node_type_entity = \Drupal\node\Entity\NodeType::load($node_type_id);


or if you have multiple node types an array of entities:

$node_type_entities = \Drupal\node\Entity\NodeType::loadMultiple($node_type_ids);