Unfortunately, the username and password you have entered do not match!

Registration

Unfortunately, this username is already taken!

Unfortunately, this e-mail address is already used!

Please retype the verification code.

All fields are required

Display information submitted in a different form

Display information submitted in a different form

In this article we will demonstrate how to easily display information submitted in a different form on your current form page using the submission's id. This id is a unique number that is automatically generated for each form submission.

The first thing you need to do is create a link in your first form that will point to the second form. This link will need to contain an additional parameter that will store the submission's id (more information regarding sending and capturing parameters from the url can be found here), for example:

 
  http://www.your-site-name.com/index.php?option=com_rsform&formId=your-second-form-id&submissionId={global:submissionid}
 

The submission ID can be easily obtained by using the global placeholder {global:submissionid}. You can find a complete list of global placeholders available in RSForm!Pro here.

After this you will need to identify the fields that you want to use. Next you will need to go to Components > RSForm!Pro > Manage forms, select your form, go to the Form layout tab and add the field placeholders of the fields you want to display in the code found on this tab, for example:

 
  <fieldset class="formFieldset">
  <legend>{global:formtitle}</legend>
  {error}
  <p>Data submitted in a different form:</p>
  <p>FullName field  : {FullName:value}</p>
  <p>Email field    : {Email:value}</p>
  <p>Age field    : {Age:value}</p>
 

The {Fullname:value}, {Email:value} and {Age:value} placeholders are the actual field placeholders of the fields you want to display the information for from your other form.

After you add all the placeholders you want in the code from the Form layout tab, you will need to go to Components > RSForm!Pro > Manage forms, select your form, go to the PHP Scripts tab and add the following code in the Scripts called on form display field:

 
  // Get the submission ID from the URL
  $submissionId = JRequest::getInt('submissionId');  
 
  if ($submissionId) {
    // Use the RSForm! Pro helper to retrieve the replacements.
    list($replace, $with) = RSFormProHelper::getReplacements($submissionId);
 
    // Replace the placeholders.
    $formLayout = str_replace($replace, $with, $formLayout);
  }
 

Set a default value in a radio / checkbox group


Another possible scenario that can be implemented in a similar manner is rendering a checkbox / radio group item in the second form as the default selection, based on the parameter transmitted in the first form. To achieve this, please add the following code in the radio / checkbox group field's Items area:

 
//<code>
// Specify the radio/checkbox group's items, they will be compared with the passed parameter.
$items = array('Item 1', 'Item 2', 'Item 3');
 
// Grab the parameter from the URL.
// The following works if the URL looks like index.php?option=com_rsform&formId=2&myparameter=some_value
$value = JRequest::getVar('myparameter');
 
// The following converts $value to an array, so that we can check multiple items
// if this is desired.
$value = (array) $value;
 
// Loop through all of the defined items.
foreach ($items as $i => $item) {
  // Checks if the current item is in our $value array.
  if (in_array($item, $value)) {
    // Use [c] to select it.
    $items[$i] .= '[c]';
  }
}
 
// Return the list of items, separated by a new line.
return trim(implode("\n", $items));
//</code>
 

Important: Starting with Version 1.49.0, the code provided above is no longer necessary, as we have introduced this functionality as a default feature. The How do I pass a parameter through the URL and how can I catch it article in our documentation explains how it's done.

Feedback