How to show the uploaded managed_file in the edit page? I am able to successfully upload files using managed_file. The file is saved in the correct directory and the record shows up in the file_managed table.

$form['image'] = array(
    '#title' =&gt; t('Image'),
    '#type' =&gt; 'managed_file',
    '#default_value' =&gt; (isset($foo-&gt;image-&gt;fid) ? $foo-&gt;image-&gt;fid : ''),
    '#upload_location' =&gt; 'public://foo_images/'
);


But when I edit the form, it still shows the Upload button, similar to the Create page before I have uploaded a file. How do I make the edit page look like I have already uploaded a file for that particular entity?
Inspecting the $foo variable showed that I was supposed to use just $foo-&gt;image instead of $foo-&gt;image-&gt;fid.

Probably because I have the following lines in my _form_submit:

if (isset($form_state['values']['image'])) {
    $file = file_load($form_state['values']['image']); 
    $file-&gt;status = FILE_STATUS_PERMANENT;
    file_save($file);
    file_usage_add($file, 'foo', 'foo', $foo-&gt;tkid);

    $foo-&gt;image = $file-&gt;fid;
  }


Notice the part that says $foo-&gt;image = $file-&gt;fid;