function filefield_file_edit_form in FileField 6.2
The filefield widget for previously uploaded files.
1 call to filefield_file_edit_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 468 - FileField: Defines a CCK file field type.
Code
function filefield_file_edit_form(&$form, &$form_state, $field, $delta, $file) {
$field_name_css = str_replace('_', '-', $field['field_name']);
$id = 'filefield-' . $field_name_css . '-' . $delta . '-form';
$classes = array(
'filefield-' . $field_name_css . '-form',
'filefield-file-form',
);
$widget = array(
'#type' => 'filefield_file_edit',
'#default_value' => $file,
'#field' => $field,
'#prefix' => '<div id="' . $id . '" class="' . implode(' ', $classes) . '"><div class="filefield-file-edit">',
'#suffix' => '</div></div>',
);
// Buttons inside custom form elements are not registered by the Forms API,
// so we make the "Delete" button a regular child element and not a part
// of the filefield_file_upload widget.
$widget['flags'] = array(
'#type' => 'markup',
'#value' => '',
'#prefix' => '<div class="filefield-file-edit-flags">',
'#suffix' => '</div>',
);
$widget['flags'][$field['field_name'] . '_' . $delta . '_delete'] = array(
'#name' => $field['field_name'] . '_' . $delta . '_delete',
'#type' => 'submit',
'#value' => t('Delete'),
'#submit' => array(
'filefield_file_edit_delete_submit',
),
// without JavaScript
'#ahah' => array(
// with JavaScript
'path' => 'filefield/js/delete/' . $field['field_name'] . '/' . $field['type_name'] . '/' . $delta,
'wrapper' => $id,
'method' => 'replace',
'effect' => 'fade',
),
'#field' => $field,
'#delta' => $delta,
'#file' => $file,
);
// Only show the list checkbox if files are not forced to be listed.
if (!$field['force_list']) {
$widget['flags']['list'] = array(
'#type' => 'checkbox',
'#title' => t('List'),
'#default_value' => $file['list'],
);
}
$edit_widget_info = filefield_widget_for_file($file, $field, $field['widget']);
$widget['edit'] = array(
'#type' => empty($edit_widget_info) ? 'filefield_generic_edit' : $edit_widget_info['form element'],
'#field' => $field,
'#delta' => $delta,
'#file' => (object) $file,
'#default_value' => $file,
'#prefix' => '<div class="filefield-file-edit-widget">',
'#suffix' => '</div>',
);
return $widget;
}