How to create a delete submission button in Manage directories


Tutorials - Tutorials

User Rating: / 0
How to create a delete submission button in Manage directories

In this article we will explain how to create a button in the Manage directories layout to delete submissions

Before we begin, we recommend reading the following articles:
    1. First of all we will create a language override to create an error in case conditions are not met.

To do this head over to Extensions > Language Manager > Overrides > New button

In the first field (Language Constant) we will give a name to the override, in this case :

The second field is the text you want to be displayed when it's executed, for this example we will use :
"You are not authorized to delete this submission."

After adding the desired text in the fields, click Save & Close

    1. Next on the to do list is a template override for the Submission directory layout
      • Copy default_layout.php from /components/com_rsform/views/directory/tmpl
      • To /templates/template_name/html/com_rsform/directory (NOTE: Match the folder structure)
      • Add to the newly copied default_layout.php, after line 39 (NOTE: It has to be after line 39 so it can be available only to the users with edit permissions):
<a href="/<?php echo JRoute::_('index.php?option=com_rsform&formId='.$this->params->get('formId').'&action=delete&id='.$item->SubmissionId); ?>">Delete</a>

Basically this line is a link to your form, with 2 custom parameters : action and submission id

    1. Now we have to create a script to check the paramenters and delete the submission values for that specific submission id

Head over to Components > RSForm!Pro > Manage Forms > Select the form > Properties > PHP scripts > And insert in the Scripts called on form display the following:

  // First we have to check the "action" parameter from the URL $action = JRequest::getWord('action'); if ($action == "delete") {   // If it returns true it will continue running the script  $id_value = JRequest::getInt('id'); $formId_value = JRequest::getInt('formId');   // For security reasons we verify if the user has the right to edit submissions using RSFormProHelper if ($id_value && $formId_value && RSFormProHelper::canEdit($formId_value,$id_value)){   // If user has enough permission rights, run the query $db = JFactory::getDbo(); $db->setQuery("DELETE FROM #__rsform_submission_values WHERE `SubmissionId`='". $id_value."'"); $db->execute(); $db->setQuery("DELETE FROM #__rsform_submissions WHERE `SubmissionId`='". $id_value."'"); $db->execute();   // Redirect the user back to Manage directories  $itemId_value = JRequest::getInt('Itemid'); $mainframe->redirect(JRoute::_('index.php?option=com_rsform&view=directory&Itemid='.$itemId_value, false)); }   // If the user does not have permission to edit, he will be prompted with the language override created earlier: else $formLayout = JText::_('RSFP_DELETE_ERROR');   }  

About Us

Royal Developer Top three Web Designing and Web Development Company in Dehradun, Uttarakhand, India. Royal Developer Best SEO Company in Dehradun takes pride in its philosophy of 'Employee First' which empowers to create a real value for the customers. Royal Developer can offer Best and cheap Website Development Software Development & SEO Services. We are the Best service Provider of SEO, SEM, SMO Services Company in Uttarakhand. Web Designing Course in Dehradun, Web Designing Classes in Dehradun, Web Design Training Institute in Dehradun, Web designing institute in dehradun, Best institute for web designing in dehradun, Web development training in dehradun, Web development course in dehradun, Web Designing Training in Dehradun.


- Contact Information - 

Add : RDIT Services Pvt Ltd, 3rd Floor, RGM Plaza, Above Chandu Canteen,
          23 Chakrata Road, Dehradun - 248001, Uttarakhand, India

Email : 


 : +91 8171200108, +91 8979462451,
                                  +91 7895753921

Quick Enquiry Form

Enter your full name

Enter your valid email address

Enter your correct mobile number

Invalid Input

Your Message
Invalid Input

Enter Code
Enter Code
  RefreshInvalid Input


You are here: Home Tutorials How to create a delete submission button in Manage directories