• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: RSForms Data retrieval

RSForms Data retrieval 9 years 9 months ago #31868

  • andy62
  • andy62's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 17
I need help to retrieve data that was entered in an RSForm (Form 1) into another RSForm (Form2). Any idea how I would even get started on this?
Andy Galloway
The administrator has disabled public write access.

RSForms Data retrieval 9 years 9 months ago #31877

  • cosmin.cristea
  • cosmin.cristea's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 756
  • Thank you received: 144
Post an accurate description of what exactly you are trying to achieve and I will try to point you in the right direction.

PS: This might help: https://www.rsjoomla.com/support/documentation/rsform-pro/custom-scripting/display-information-submitted-in-a-different-form.html
My help is not official customer support. To receive your support, submit a ticket by clicking here
Last Edit: 9 years 9 months ago by cosmin.cristea.
The administrator has disabled public write access.

RSForms Data retrieval 9 years 9 months ago #31901

  • andy62
  • andy62's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 17
Sorry but that article did not explain what I need to do. This is a very simple thing and I'm sure you guys do it all the time - retrieve data that was previously submitted in form 1 and display it in a form field on form 2. That's it.

You wanted a bit more detail, so ...

I have used the Joomla Registration Plug In and I have created a form (called "Company Registration" alias co-reg, form ID = 3) that collects all of the information for the User functionality and a lot of additional information that I required from the user (i.e. company name, address, phone number, etc.)

I want to open another form (called "Controller Registration" alias ct-reg, form ID = 4) and retrieve information from the "Company Registration" form and load it in form fields. Can you provide some simple script to show me how to show the company name (fieldname "Company") previously submitted in the "Company Registration" form in the "Controller Registration" form?

Secondly, when the user submits the "Company Registration" form, I would like to create a new field called "AccountNo" and add it to the database. This "calculated" field would consist of the first letter of the company name and an incrementing number. For example "Acme Co" might be "A1234" then when "Bloggs & Co" register they would be "B1235" and "Acorn Ltd" would become "A1236" when they register. Can you provide an example of how I could go about doing this?

Thanks in anticipation of your assistance.
Andy Galloway
Last Edit: 9 years 9 months ago by andy62. Reason: Simply my request
The administrator has disabled public write access.

RSForms Data retrieval 9 years 9 months ago #31945

  • andy62
  • andy62's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 17
Hi Cosmin. I updated my post to give you the detail you requested. This is a very simple task, I just don't know how to use RSForm or Joomla to make it happen. It will probably take you about 30 seconds to answer my query.

Yours in desperation.

Andy Galloway
Andy Galloway
The administrator has disabled public write access.

RSForms Data retrieval 9 years 9 months ago #31966

  • Ken06
  • Ken06's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 7
  • Thank you received: 4
Here is what I have done...

You used "Company Name" in your example, so I will show how to do that one.

On your first form (Company Registration), go to "Properties" -> "PHP Script" tab. The last box is the "Script called after form has been processed" box. In there, put the following 4 lines:
if(session_id() == '') {
    session_start();
}
$_SESSION['form_company_registration'] = $SubmissionId;

This will set the Assign the Submission Id to a session variable that can be retrieved on the next form.


Then on your second form (Controller Registration), you will need to copy the code below (including the //<code> parts) to set the "Default Value" for each field you want to pull over. Note that you will need to change FieldName to to be the FieldName (not caption) of the previous form.

//<code> 
session_start();
 
$db =& JFactory::getDBO();
 
$sql = "Select FieldValue from #__rsform_submission_values WHERE SubmissionId=".$_SESSION['form_company_registration']." AND FieldName='Company Name';";
$db->setQuery($sql);
$result = $db->loadResult();
 
return $result;
//</code>

This works great for text boxes, however if you have a dropdown or option/radio buttons, it gets a little trickier. (Let me know and I'll pull some examples)

While this unfortunately makes a bunch of database hits, it is the easiest solution I can provide in the 20 minutes it took me to put this together for you. ... mainly because that is how I have done it on one of my sites. :)

If I had to start over and I had more than 5-10 fields to pull over, I would consider putting logic in the "Script called on form display" box to do one database hit to pull over all fields from the "Company Registration" form, throw them into an array and then have the "Default Value" on the fields within the "Controller Registration" pull from that array. If you are a programmer and want to go this route, I encourage you to do so, then post your solution back here.

I hope that helps. :) Thanks!
Last Edit: 9 years 9 months ago by Ken06.
The administrator has disabled public write access.
The following user(s) said Thank You: andy62

RSForms Data retrieval 9 years 9 months ago #31969

  • andy62
  • andy62's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 17
Thanks for the code above. I will add it to my forms later today.

Meanwhile, I am interested in what you say about the method to pull data from several fields across to a new form. I believe this is the method that I will need in order to develop my web site (more of an on-line application). Would you be able to provide the methodology or the code to enable that functionality? If you keep it simple and work just with the two forms and the one field that we spoke about previously, I can add other forms and fields later.

Thanks in advance for your help.
Andy Galloway
The administrator has disabled public write access.

RSForms Data retrieval 9 years 8 months ago #32049

  • Ken06
  • Ken06's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 7
  • Thank you received: 4
Hi Andy,

Essentially, instead of pulling data at a field level from each item on your second form, I suggest that you pull back data at a form level from the "Script called on form display" box on your second form and put it into an array/object. Then, from each field on the second form, pull the value from that array/object.

Did that make more sense? :-/

Thanks!
The administrator has disabled public write access.

RSForms Data retrieval 9 years 8 months ago #32050

  • andy62
  • andy62's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 17
I set this code up and ran it. The new form was created with the company name in the correct field (well done). However, I also got the following text at the top of the page:

Strict Standards: Only variables should be assigned by reference in /var/sites/s/screenme.co.uk/public_html/administrator/components/com_rsform/helpers/rsform.php(574) : eval()'d code on line 4

Any idea what I have done wrong and how to fix it?
Andy Galloway
The administrator has disabled public write access.

RSForms Data retrieval 9 years 8 months ago #32051

  • andy62
  • andy62's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 17
The theory makes perfect sense. However, translating that into code is a bit more difficult. A little more detail would be greatly appreciated.
Andy Galloway
The administrator has disabled public write access.

RSForms Data retrieval 9 years 8 months ago #32055

  • Ken06
  • Ken06's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 7
  • Thank you received: 4
Hi Andy. I apologize, but to give more detail would be to provide code examples. Since I've not done it this way, I don't have any code samples to provide. Again, sorry that I'm not more help.
The administrator has disabled public write access.
The following user(s) said Thank You: andy62

RSForms Data retrieval 9 years 8 months ago #32058

  • alexp
  • alexp's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 2253
  • Thank you received: 180
andy62 wrote:
I set this code up and ran it. The new form was created with the company name in the correct field (well done). However, I also got the following text at the top of the page:

Strict Standards: Only variables should be assigned by reference in /var/sites/s/screenme.co.uk/public_html/administrator/components/com_rsform/helpers/rsform.php(574) : eval()'d code on line 4

Any idea what I have done wrong and how to fix it?

No need to worry about the warning message. You inhibit this from displaying by adjusting the global Joomla! error reporting level.

PS: This is most likely caused by the following line:
$db =& JFactory::getDBO();

Replace it with the following:
$db = JFactory::getDBO();
Please note: my help is not official customer support. To receive your support, submit a ticket by clicking here
Regards,
RSJoomla! Development Team
The administrator has disabled public write access.
The following user(s) said Thank You: andy62

RSForms Data retrieval 9 years 8 months ago #32072

  • andy62
  • andy62's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 17
I'm a little confused by the use of terms like "#__table_name" and "variable". Can you help me?

1. I have a form called "Company Registration" and a field in that form called "Account". When I go to a different form, how can I call that data and put it into another field on that new form? I know the theory having worked with SQL statements since they were first invented, but PHP does not appear to be logical.

2. In the RS Form Pro documentation, you talk about "variables" when you really mean "data fields". In PHP it is possible to use "real" variables (for example "varCompanyName" or "$varCompanyName") but there is no mention of how to set these variables when submitting a form or how to get them to populate a field on a new form. Can you help me with this?
Andy Galloway
The administrator has disabled public write access.

RSForms Data retrieval 9 years 8 months ago #32078

  • alexp
  • alexp's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 2253
  • Thank you received: 180
Implementing scripts such as these require some PHP/MySQL/Joomla! familiarization. Note that this isn't something RSForm!Pro specific.

"#__table_name" - is the actual database table name that you want to extract data from.

"variable" - symbolic / reference to some data or set. This is a generic programming term. Perhaps Google can shed more light on this for you.

Various script samples are available here:

https://www.rsjoomla.com/support/documentation/rsform-pro/custom-scripting.html
Please note: my help is not official customer support. To receive your support, submit a ticket by clicking here
Regards,
RSJoomla! Development Team
The administrator has disabled public write access.

RSForms Data retrieval 9 years 8 months ago #32086

  • andy62
  • andy62's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 17
I've read all of the script samples and articles in the User Manual. Nowhere does it tell me how to find the table name to which the data has been submitted. This is driving me nuts. In all other languages I decide the names of the tables (databases) into which I insert the data. How can I find out where RSForm Pro has put my data? If I have a form called "Company Registration", do I retrieve data from a table called "#__rsform_Company_Registration"? Or, if the alias is "co-reg" do I retrieve my data from a table called "#__rsform_co-reg"? I can't make either of these options work. Alternatively, is there a comprehensive reference work on how Joomla works with databases? I belong to about 5 different Joomla fora and they all refer me back to this forum as it is to do with RSForm Pro.

Also, the use of the term "variable" in this User Manual is inconsistent with all other programming languages that I have used, and I've been programming computers since 1976 in over a dozen computer languages - just not in Joomla. It's not a problem to call "data" a "variable", as long as I know that, for Joomla, the two terms appear to be interchangeable.
Andy Galloway
The administrator has disabled public write access.

RSForms Data retrieval 9 years 8 months ago #32202

  • RPPEO
  • RPPEO's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 68
  • Thank you received: 6
Andy I feel your pain as I'm doing something like this now. I find in general that documentation in Joomla Land is pretty much expecting you to know what to do.

This link help me to get most of it setup: www.rsjoomla.com/support/documentation/r...-different-form.html

Step 1
This goes on your form 1:
www.your-site-name.com/index.php?option=...{global:submissionid}

In form 2 paste the PHP Script from the link above as per the instructions also in the link above.

Now in each Text Box component's "default value" you enter the fieldname and value for example:
if Form 1 has a textbox called name
on form 2 call this textbox Name
the "Default value" is {name:value}
the textbox on form2 called Name will display the value from the textbox name on form 1.
Repeat for all the textbox values you want to display in From 2 from Form 1.
Savvy?

For Dropdowns etc...

To call Form2 and insert the values from a Form 1 submission use the same URL from step 1. For my purposes this is done with a Menu Item - RSFORM - Submission View. Options tab - Row Layout include something like:
<a class="button" href="index.php?option=com_rsform&formId=2&submissionId={global:submissionid}">Update Form1 with Form2</a>

Good luck
The administrator has disabled public write access.
The following user(s) said Thank You: andy62

RSForms Data retrieval 9 years 8 months ago #32203

  • andy62
  • andy62's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 17
RPPEO, thanks for your input. I wanted to avoid using the default values in fields as it feels a little clunky to me. I wanted to do it all in one PHP script on loading the form. However, it appears that is not an option or it would be to long winded to code it manually.

I'll work through your suggestions for the methodology over the weekend (deep joy!). Thanks again.
Andy Galloway
The administrator has disabled public write access.

RSForms Data retrieval 9 years 8 months ago #32226

  • RPPEO
  • RPPEO's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 68
  • Thank you received: 6
Andy my developer came up with this to grab values from com_contact and populate the address fields for users with contact info.
$user = JFactory::getUser();
$userId= $user->get("id");
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('*')
->from($db->quoteName('#__contact_details'))
->where($db->quoteName('user_id') . ' = '. $db->quote($userId));
$db->setQuery($query);
$my_value = $db-> loadRow ();
$formLayout=str_replace("name_5959188",$my_value['1'], $formLayout );
$formLayout=str_replace("email_5959188",$my_value['13'], $formLayout );
$formLayout=str_replace("address_5959188",$my_value['4'], $formLayout );
$formLayout=str_replace("homephone_5959188",$my_value['9'], $formLayout );
$formLayout=str_replace("city_5959188",$my_value['5'], $formLayout );
$formLayout=str_replace("province_5959188",$my_value['6'], $formLayout );
$formLayout=str_replace("postalcode_5959188",$my_value['8'], $formLayout );
$formLayout=str_replace("cellphone_5959188",$my_value['23'], $formLayout );

Stick the values above (name_5959188, email_595188...) in default values for your components.

Cheers.
The administrator has disabled public write access.

RSForms Data retrieval 9 years 8 months ago #32341

  • sudhi
  • sudhi's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
>>This works great for text boxes, however if you have a dropdown or option/radio buttons, it gets a little trickier. (Let me know and I'll pull some examples)

Hi - Grateful if you can share examples of pulling data into drop down lists and checkboxes. Many thanks.
Sudhi
The administrator has disabled public write access.

RSForms Data retrieval 9 years 7 months ago #32352

  • Ken06
  • Ken06's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 7
  • Thank you received: 4
Playing off of the example in my previous post:
www.rsjoomla.com/forum/37-rsform-pro/260...retrieval.html#31966

I've added a bunch of examples. I hope that you are able to mash up what you need or at least get an idea how this whole process works. :) Good luck!

******************** Single Check Box ********************
//<code> 
session_start();
 
$db =& JFactory::getDBO();
 
$sql = "Select FieldValue from #__rsform_submission_values WHERE SubmissionId=".$_SESSION['form_company_registration']." AND FieldName='Your Fieldname Here';";
$db->setQuery($sql);
$result = $db->loadResult();
 
return 'Check Box Value Here'.(strlen($result) > 0 ? '[c]' : '');
//</code>


******************** Check Box Group ********************
//<code> 
session_start();
 
$db =& JFactory::getDBO();
 
$sql = "Select FieldValue from #__rsform_submission_values WHERE SubmissionId=".$_SESSION['form_company_registration']." AND FieldName='States Covered';";
$db->setQuery($sql);
$result = $db->loadResult();
$results = explode("\n", $result);
 
$values = array('NE', 'IA', 'KS', 'MO');
 
foreach($values as $key => $value)
{
	if(in_array($value, $results))
	{
		$values[$key] = $value.'[c]';
	}
}
 
return implode("\n", $values);
//</code>


******************** Dropdown ********************
//<code> 
session_start();
 
$db =& JFactory::getDBO();
 
$sql = "Select FieldValue from #__rsform_submission_values WHERE SubmissionId=".$_SESSION['form_company_registration']." AND FieldName='Company Type';";
$db->setQuery($sql);
$result = $db->loadResult();
 
$values = array('-','Sole Proprietorship','LLC','Corporation');
 
foreach($values as $key => $value)
{
	if($value == $result)
	{
		$values[$key] = $value.'[c]';
	}
}
 
return implode("\n", $values);
//</code>


******************** Radio Buttons ********************
//<code> 
session_start();
 
$db =& JFactory::getDBO();
 
$sql = "Select FieldValue from #__rsform_submission_values WHERE SubmissionId=".$_SESSION['form_company_registration']." AND FieldName='Ever Filed For Bankruptcy';";
$db->setQuery($sql);
$result = $db->loadResult();
 
$values = array('Yes','No');
 
foreach($values as $key => $value)
{
	if($value == $result)
	{
		$values[$key] = $value.'[c]';
	}
}
 
return implode("\n", $values);
//</code>
The administrator has disabled public write access.
The following user(s) said Thank You: patrick.jackson, stevent

RSForms Data retrieval 9 years 7 months ago #32469

  • patrick.jackson
  • patrick.jackson's Avatar
  • OFFLINE
  • Junior Boarder
  • Joomla Consultant, Melbourne Australia
  • Posts: 22
  • Thank you received: 4
Ken,

Very nice work. Very quickly solved most of an issue I was having expanding on the documentation about displaying submitted form in another form.

Only variation that I'm after is that I have different values and option text displayed using | between the values. So the value gets saved in the database, but I'd still like to show the different option text in some cases.

Any thoughts?
Joomla Consultant & Hosting Provider
Melbourne Australia
The administrator has disabled public write access.

RSForms Data retrieval 9 years 4 months ago #33402

  • stevent
  • stevent's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 23
  • Thank you received: 1
This code does a query for each dropdown menu. I was wondering if there would be a way to get all the submitted data at once when loading the form, and then preselecting all the fields. I've added this trick to a form with multiple dropdown's, adding 9 extra queries (to a form that already has queries to populate drop down's base on a table)
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!