"managed_file" form field type returns null value in my form submission I am have been struggling with this for the past day or so. I am simply trying to create a custom entity and populate/or update the image field with the fid. Whats weird is that every other form field I am passing I can get the value for but this managed_file field for uploading an image always returns NULL when I call dpm(). 

use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\file\Entity\File;


Within my form_build function, I use the following code. 

// Manage file.
$form['theimage'] = array(
  '#type' =&gt; 'managed_file',
  '#title' =&gt; 'Managed file',
  '#description' =&gt; $this-&gt;t('Manage file, #type = managed_file'),
  //'#default_value' =&gt; $form_state-&gt;getValue('theimage'),
  '#upload_location' =&gt; 'public://images/',
  '#required' =&gt; FALSE,
);


In the submission handler, I use the following code. 

// Get the fid value, upload it and save it to the managed file table. 
$fid = $form_state-&gt;getValue(['theimage', 0]);
dpm($fid);
if (!empty($fid)) {
  $file = File::load($fid);
  $file-&gt;setPermanent();
  $file-&gt;save(); 
}


Any thoughts, solutions, or recommendations would be greatly appreciated.
After alot of digging/debugging i discovered that i could not pull any data from the "manage_file" field while using the PrivateTempStore in my Multi-Step form. After disabling the form cache, i began to get the values and the expected behavior by using: 

$form_state-&gt;disableCache(); 


My Submit Handler   

public function buildForm(array $form, FormStateInterface $form_state) {
 /**
 *  Fixes image upload bug in form. Does not work unless we 
 disable the cache while using PrivateTempStore
 **/

 $form_state-&gt;disableCache();

.......

}


See https://www.drupal.org/project/drupal/issues/2647812#comment-11683961