function filefield_file_upload_form in FileField 6.2
The filefield widget for not (yet) existing files.
1 call to filefield_file_upload_form()
- filefield_widget in ./
filefield.widget.inc - Implementation of hook_widget() - the one in filefield.module is just there to include this one on demand.
File
- ./
filefield.widget.inc, line 34 - FileField: Defines a CCK file field type.
Code
function filefield_file_upload_form(&$form, &$form_state, $field, $delta, $items) {
$form['#attributes']['enctype'] = 'multipart/form-data';
// Include JavaScript for client-side file validation.
drupal_add_js(drupal_get_path('module', 'filefield') . '/filefield.js');
$field_name_css = str_replace('_', '-', $field['field_name']);
$id = 'filefield-' . $field_name_css . '-' . $delta . '-form';
$replaced_file = isset($items[$delta]) && isset($items[$delta]['replaced_file']) ? $items[$delta]['replaced_file'] : NULL;
$requirements = _filefield_upload_requirements($field, $field['widget'], $items);
$widget = array(
'#type' => 'filefield_file_upload',
'#field' => $field,
'#delta' => $delta,
'#replaced_file' => $replaced_file,
'#prefix' => '<div id="' . $id . '" class="filefield-file-form"><div class="filefield-file-upload">',
'#suffix' => '</div></div>',
'#upload_requirements' => $requirements,
);
if ($requirements['upload possible']) {
// Buttons inside custom form elements are not registered by the Forms API,
// so we make the "Upload" button a regular child element and not a part
// of the filefield_file_upload widget.
$widget[$field['field_name'] . '_' . $delta . '_upload'] = array(
'#name' => $field['field_name'] . '_' . $delta . '_upload',
'#type' => 'submit',
'#value' => t('Upload'),
'#submit' => array(
'filefield_file_upload_submit',
),
// without JavaScript
'#ahah' => array(
// with JavaScript
'path' => 'filefield/js/upload/' . $field['field_name'] . '/' . $field['type_name'] . '/' . $delta,
'wrapper' => $id,
'method' => 'replace',
'effect' => 'fade',
),
'#weight' => 10,
'#field' => $field,
'#delta' => $delta,
);
}
return $widget;
}