I have a custom form module with a field of type 'managed_file', and an entry in the database pointing to an image's filepath.
I would like to pre-load this image into the 'managed_file' field when the form is first displayed.
I've tried assigning #default_value to the image's filepath, but this does nothing.
What is the best way to go about doing this?
$result = db_query('SELECT n.companyName, n.billingEmail, n.leadEmail, n.contactEmail, n.contactEmail,
n.url, n.description, n.companyLogo, n.promoVideoUrl
FROM {leads_client} n WHERE n.clientId = :uid', array(':uid' => $GLOBALS['user']->uid));
$row = $result->fetchAssoc();
$form['company_logo'] = array(
'#type' => 'managed_file',
'#title' => t('Company Logo'),
'#description' => t('Allowed extensions: gif png jpg jpeg'),
'#upload_location' => 'public://uploads/',
'#default_value' => $row['companyLogo'],
'#upload_validators' => array(
'file_validate_extensions' => array('gif png jpg jpeg'),
// Pass the maximum file size in bytes
'file_validate_size' => array(1024*1024*1024),
),
);