function _filefield_file_form in FileField 5.2
1 call to _filefield_file_form()
File
- ./
filefield.module, line 582 - Defines a file field type.
Code
function _filefield_file_form($node, $field, $file) {
// Lets be a good boy and initialize our variables.
$form = array();
$form['#after_build'] = array(
'_filefield_file_form_description_reset',
);
$form['icon'] = array(
'#type' => 'markup',
'#value' => theme('filefield_icon', $file),
);
$form['file_preview'] = array();
$filepath = $file['fid'] == 'upload' ? file_create_filename($file['filename'], file_create_path($field['widget']['file_path'])) : $file['filepath'];
$url = file_create_url($filepath);
$form['description'] = array(
'#type' => 'textfield',
'#default_value' => strlen($file['description']) ? $file['description'] : $file['filename'],
'#maxlength' => 256,
'#size' => 40,
'#attributes' => array(
'class' => 'filefield-description',
'size' => '40',
),
);
$form['url'] = array(
'#type' => 'markup',
'#value' => l($url, $url),
'#prefix' => '<div class="filefield-edit-file-url">',
'#suffix' => '</div>',
);
$form['size'] = array(
'#type' => 'markup',
'#value' => format_size($file['filesize']),
'#prefix' => '<div class="filefield-edit-file-size">',
'#suffix' => '</div>',
);
$form['delete'] = array(
'#type' => 'checkbox',
'#default_value' => $file['delete'],
);
// Only show the list checkbox if files are not forced to be listed.
if (!$field['force_list']) {
$form['list'] = array(
'#type' => 'checkbox',
'#default_value' => $file['list'],
);
}
else {
$form['list'] = array(
'#type' => 'value',
'#value' => isset($file['list']) ? $file['list'] : 1,
);
}
$form['filename'] = array(
'#type' => 'value',
'#value' => $file['filename'],
);
$form['filepath'] = array(
'#type' => 'value',
'#value' => $file['filepath'],
);
$form['filemime'] = array(
'#type' => 'value',
'#value' => $file['filemime'],
);
$form['filesize'] = array(
'#type' => 'value',
'#value' => $file['filesize'],
);
$form['fid'] = array(
'#type' => 'value',
'#value' => $file['fid'],
);
// Remember the current filename for the check in
// _filefield_file_form_description_reset() that happens after submission.
$form['previous_filepath'] = array(
'#type' => 'hidden',
'#value' => $file['filepath'],
);
foreach (module_implements('filefield') as $module) {
$function = $module . '_filefield';
$function('file_form', $node, $field, $file, $form);
}
return $form;
}