Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Form Questions /

Delete Submission


Reply


5 Posts   1284 Views

Avatar
plushtoy

Community Member, 10 Posts

15 January 2010 at 9:32am

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>

Avatar
Willr

Forum Moderator, 5513 Posts

15 January 2010 at 12:08pm

Welcome to the Forums,

Are you working with the site in devmode?. If its devmode then you'll hopefully get a much more informative error message. You can make sure your site is in devmode by adding 'Director::set_environment_type("dev");' in your _config.php

Avatar
plushtoy

Community Member, 10 Posts

15 January 2010 at 1:21pm

Hi Willr,

After adding 'Director::set_environment_type("dev");' to _config.php, I am still receiving the same error. Did I add the code in the right place? I appreciate your assistance with this.

Director::addRules(50, array(
   'processes//$Action/$ID/$Batch' => 'BatchProcess_Controller',
   'admin/help//$Action/$ID' => 'CMSHelp',
   'admin/ReportField//$Action/$ID/$Type/$OtherID' => 'ReportField_Controller',
   'admin/bulkload//$Action/$ID/$OtherID' => 'BulkLoaderAdmin',
   'admin//ImageEditor/$Action' => 'ImageEditor',
   'admin/cms//$Action/$ID/$OtherID' => 'CMSMain',
   'PageComment//$Action/$ID' => 'PageComment_Controller',
   'dev/buildcache' => 'RebuildStaticCacheTask',
));

CMSMenu::populate_menu();

HTTP::set_cache_age(0);

'Director::set_environment_type("dev");'

Avatar
Willr

Forum Moderator, 5513 Posts

15 January 2010 at 1:25pm

You don't need the ' round the Director::set_environment_type("dev"); just put

Director::set_environment_type("dev");

Avatar
plushtoy

Community Member, 10 Posts

16 January 2010 at 3:08am

Hi Willr,

Added as directed:
Director::set_environment_type("dev");

Still receiving just this error:

Website Error
Forbidden
The website server has not been able to respond to your request.

SilverStripe version 2.3.2

Thank you!