You are here

function filefield_file_edit_delete in FileField 6.2

Update the form state so that the file for the given field and delta is marked as deleted.

2 calls to filefield_file_edit_delete()
filefield_file_edit_delete_js in ./filefield.widget.inc
Form callback for the "Delete" button with JavaScript enabled, invoked by filefield_js(). Marks the file in the given field and delta as deleted, or deletes it right away (depending on the context).
filefield_file_edit_delete_submit in ./filefield.widget.inc
Submit callback for the "Delete" button next to each file item.

File

./filefield.widget.inc, line 610
FileField: Defines a CCK file field type.

Code

function filefield_file_edit_delete(&$form_state, $field, $delta) {
  $field_name = $field['field_name'];
  $file =& $form_state['values'][$field_name][$delta];
  if (isset($file['status']) && $file['status'] == FILE_STATUS_PERMANENT) {
    $file['delete'] = 1;
    $file = array(
      'fid' => 0,
      'replaced_file' => $file,
    );
  }
  else {

    // temporary file, get rid of it before it's even saved
    $empty_file = array(
      'fid' => 0,
      'replaced_file' => $file['replaced_file'],
    );
    field_file_delete($file);
    $file = $empty_file;
  }
  return $file;
}