function theme_webform_render_file in Webform 6.3
Render a File component.
File
- components/
file.inc, line 329 - Webform module file component.
Code
function theme_webform_render_file($element) {
// Add information about the existing file, if any.
if (isset($element['#default_value'])) {
$element['_fid']['#value'] = $element['#default_value'];
}
$value = $element['_fid']['#value'] ? $element['_fid']['#value'] : $element['_old']['#value'];
if ($value && ($file = webform_get_file($value))) {
$firstchild = array_shift(element_children($element));
$element[$firstchild]['#suffix'] = ' ' . l(t('Download @filename', array(
'@filename' => webform_file_name($file->filepath),
)), webform_file_url($file->filepath)) . (isset($element['#suffix']) ? $element['#suffix'] : '');
$element[$firstchild]['#description'] = '<div class="webform-newfile-message">' . t('Uploading a new file will replace the current file.') . '</div>' . (isset($element[$firstchild]['#description']) ? $element[$firstchild]['#description'] : '');
}
// Add the required asterisk.
if ($element['#webform_required']) {
$element[$element['#webform_form_key']]['#required'] = TRUE;
}
$output = '';
foreach (element_children($element) as $key) {
$output .= drupal_render($element[$key]);
}
return $output;
}