After uploading a file with the File widget for the File field, the file is on the server and remove only disassociates the file from the field (and the content that the field belongs to).
I would like to add a button to actually delete the file. I've considered a number of options: - via hook_form_alter - but unsure as to what to insert into the $form or $form_state array for the content edit form, regarding new array elements and at what position - by providing a theme .tpl file (based on what devel_themer suggests - tried a few possibilities by the themes did not 'fire' (execute) - making use of the API in https://www.drupal.org/project/extended_file_field to write a hook or otherwise in a custom module
Which of the above would be the standard programmatical approach for extending the file widget to provide direct deletion of the file?
Update
I set my debugger to fire on the function file_managed_file_submit($form, &$form_state)
that Geoff mentioned. On clicking the Remove button to the right of the file...
The function file_managed_file_submit($form, &$form_state)
is called BUT the status
is not zero, so the if fails and the delete does not happen - see debug screen below showing all of this:
This commenter has also seen the problem it seems: how to delete the files uploaded in the file field?
Update 2 I think I know what's going on: We have Workbench Moderation on the site. So, it would make sense to not delete the file but rather the remove just disassociates the file from the Current revision of the content. This makes sense if in previous revisions, they did actually need to refer to the file. So by keeping the file present means those previous revisions "integrity" is intact in that they still refer to the file and the link is not broken. So in summary this is 'as design' I think. Thoughts?
(There is a way to properly delete the file through admin/content/file
)