Display Last Edited Date in Submissions Directory

By default, RSForm!Pro's Submissions Directory menu item can only be configured to display the date and time the submission was made on, not when it was last modified. However, due to the component's extended flexibility, this can be implemented with custom scripting. In this article we will provide a step-by-step guide to achieving such a functionality.


Some modifications will need to be performed for both the form you are adding this for, and its submissions directory (displayed information and a custom script).


The form


We will record the last time a submission was edited in a hidden field:


  • Head to Components >> RSForm!Pro >> Manage Forms >> edit your form >> Components
  • Add a hidden field to the form and edit it
  • In its Default Value area add Never. This value will be later updated by our custom code which will be triggered when a user will modify his submission.

  • Submissions Directory (configuration and code)


    Configuration


    The Submissions Directory will need to be configured in such manner so that the hidden field which holds the last time the submission was edited on will be displayed in the listing, details and in the editing layouts:


    • Head to Components >> RSForm!Pro >> Manage Directories >> edit your form's directory >> Directory Fields and check your hidden field in the Show in Listing, Show in Details and Editable columns
    • Next head to Components >> RSForm!Pro >> Manage Directories >> edit your form's directory >> Emails , click the New email button and configure the required fields. This email is only needed in order to trigger the script from the Script called before the Directory Emails are sent area.

    The custom code


    The final step in our implementation is to add the custom code that will record the last edited date and time. You can also disable the email that was configured previously, this way you can record the edit time, but not be forced to send an email.


    • Head to Components >> RSForm!Pro >> Manage Directories >> edit your form's directory >> PHP Scripts and add the following code in the Script called before the Directory Emails are sent area:
     
    $directoryEmail['to'] = '';
    $directoryEmail['from'] ='';
     
    $db = JFactory::getDbo();
    $db->setQuery("UPDATE #__rsform_submission_values SET `FieldValue`='".date('m/d/y H:i:s')."' WHERE `SubmissionId`=".$SubmissionId." AND 
    FieldName='name_of_hidden_field'");
    $db->query();
     
    NOTE: Make sure to replace name_of_hidden_field with your hidden field's actual name.

    One person found this article helpful.


    Was this article helpful?

    Yes No
    Sorry about that

    You Should Also Read

    Show or hide fields HOT

    Fields are not showing up in the frontend HOT

    Set up conditionals for groups of fields

    Hidden fields take up space in the form

    Calculate user's age using BirthDay field