function media_resource_display_user_files_form in D7 Media 6
Display files in a form element.
This is a generic for other modules to make use of.
Parameters
array $files: array of (uri => uri, filename => filename, meta => array(key => value))
string $title: option title argument
Return value
array Form array containing a select list populated with files.
3 calls to media_resource_display_user_files_form()
- media_media_mover_all_files in media_media_mover/
media_media_mover.module - Retrives all media mover files for reuse
- media_media_mover_user_files in media_media_mover/
media_media_mover.module - Retrives users media mover files
- media_upload_user_files_select in media_upload/
media_upload.module - Implementation of callback media_upload_media_user_files_select().
File
- ./
media.module, line 797 - Media API
Code
function media_resource_display_user_files_form($files, $title = NULL) {
// Pass files into options array.
$options = array();
foreach ($files as $file) {
// TODO: Use FID rather than URI
$options[$file['uri']] = $file['filename'];
}
// Parse files into form element.
$form['media_files'] = array(
'#type' => 'select',
'#options' => $options,
'#title' => $title ? $title : '',
'#attributes' => array(
'class' => 'resource select',
),
'#size' => variable_get('media_file_list_size', 10),
);
return $form;
}