Drupal Answers Asked by pglatz on November 11, 2021
I’ve added a multiple image field to the user account that uses the multiupload_imagefield_widget
and it works when I edit the account.
On the other hand, I have a custom module with a form that I would like to edit just this field (I have a submit handler to update the user data). I call user_load
to display the data and I can see the data is there in the debugger, but no images are displayed on the form.
What do I have to do to make them show up?
Here’s my code:
$user_data = user_load($user->uid);
$form['my_imageGallery'] = array(
'#type' => 'image',
'#title' => t('Image Gallery'),
'#default_value' => isset($user_data->field_galeria) ? $user_data->field_galeria : null,
'#upload_location' => 'public://user_galleries/',
'#upload_validators' => array('file_validate_extensions' => array('png jpg gif')),
);
I think you need to use a managed_file
form element.
$user_data = user_load($user->uid);
$form['my_imageGallery'] = array(
'#type' => 'managed_file',
'#title' => t('Image Gallery'),
'#default_value' => isset($user_data->field_galeria) ? $user_data->field_galeria : null,
'#upload_location' => 'public://user_galleries/',
'#upload_validators' => array('file_validate_extensions' => array('png jpg gif')),
);
Answered by Chris Happy on November 11, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP