I am attempting to provide a way for users to delete form submissions through the admin but receive this error. Is there a better way to do this? Thanks!
Website Error Forbidden
The website server has not been able to respond to your request.
UserDefinedForm.php - added below function delete()
[code}
/**
* Remove a submitted form.
*
* This only breaks the relation, leaving the record in the database.
* Permission checks stop non-administrators from accessing this method.
*/
function deletesubmission() {
if(Permission::check('ADMIN')) {
if($submissionID = Director::urlParam('ID')) {
if($submission = DataObject::get_by_id('SubmittedForm', (int)$submissionID)) {
$this->Submissions()->remove($submission);
}
}
Director::redirectBack();
} else {
Security::permissionFailure($this, 'You must be an administrator to perform this action');
}
}
SubmittedFormReportField.ss - added this line, just below the line 'Submitted at...'
<a href="{$Parent.Link}deletesubmission/$ID">Delete this submission</a>