Jump to:

2002 Posts in 1422 Topics by 616 members

Form Questions

SilverStripe Forums » Form Questions » Delete Submission

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1213 Views
  • plushtoy
    Avatar
    Community Member
    10 Posts

    Delete Submission Link to this post

    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>

  • Willr
    Avatar
    Forum Moderator
    5489 Posts

    Re: Delete Submission Link to this post

    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

  • plushtoy
    Avatar
    Community Member
    10 Posts

    Re: Delete Submission Link to this post

    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");'

  • Willr
    Avatar
    Forum Moderator
    5489 Posts

    Re: Delete Submission Link to this post

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

    Director::set_environment_type("dev");

  • plushtoy
    Avatar
    Community Member
    10 Posts

    Re: Delete Submission Link to this post

    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!

    1213 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.