function s3fs_cors_remove_submit in S3 File System CORS Upload 7
Submit callback for the remove button on s3fs_cors elements.
1 string reference to 's3fs_cors_remove_submit'
- s3fs_cors_upload_process in ./
s3fs_cors.module - Element process function for s3fs_cors_upload element.
File
- ./
s3fs_cors.module, line 474 - Allow uploading of files directly to AmazonS3 via the browser using CORS.
Code
function s3fs_cors_remove_submit($form, &$form_state) {
$parents = $form_state['triggering_element']['#array_parents'];
// Drop the button_key value off the end of the parents array, since we don't need it.
array_pop($parents);
$element = drupal_array_get_nested_value($form, $parents);
// If it's a temporary file we can safely remove it immediately, otherwise
// it's up to the implementing module to clean up files that are in use.
if ($element['#file'] && $element['#file']->status == 0) {
file_delete($element['#file']);
}
// Update both $form_state['values'] and $form_state['input'] to reflect
// that the file has been removed, so that the form is rebuilt correctly.
// $form_state['values'] must be updated in case additional submit handlers
// run, and for form building functions that run during the rebuild, such as
// when the s3fs_cors_upload element is part of a field widget.
// $form_state['input'] must be updated so that s3fs_cors_upload_value()
// has correct information during the rebuild.
$values_element = $element['#extended'] ? $element['fid'] : $element;
form_set_value($values_element, NULL, $form_state);
drupal_array_set_nested_value($form_state['input'], $values_element['#parents'], NULL);
// Set the form to rebuild so that $form is correctly updated in response to
// processing the file removal.
$form_state['rebuild'] = TRUE;
}