• 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: Multiple Field pull from previous form

Multiple Field pull from previous form 3 years 8 months ago #41499

  • brian905
  • brian905's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
Hello,

I am needing some help when it comes to pulling submission data from a previous form using a code snippet.

I am able to pull the form data for one field, but when I try to load another field value into the variable, it errors out.

Any thoughts? I am tring to pull the fields FirstName and LastName.

//<code>
$items = array();
$db = JFactory::getDbo();
$items[] = "|Select an Applicant[c]";
$db->setQuery("SELECT FieldValue, FieldName FROM #__rsform_submission_values WHERE FormId = 4 AND FieldName = 'FirstName'");
$results = $db->loadObjectList();
foreach ($results as $result) {
$value = $result->FieldValue;
$label = $result->FieldName;
$items[] = $value.'|'.$value;
}
$items = implode("\n", $items);
return $items;
//</code>
The administrator has disabled public write access.

Multiple Field pull from previous form 3 years 7 months ago #41565

  • brian905
  • brian905's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
Hello,

I actually figured out a way to get this done and shorten the code. Plus i didn't have to implode as it was defined in the initial string.

//<code>
// Prepare the empty array
$items = array();

// Prepare the database connection
$db = JFactory::getDbo();
// Keep this if you'd like a "Please select" option, otherwise comment or remove it
$items[] = "|Please Select[c]";

// Run the SQL query and store it in $results
$db->setQuery("SELECT FirstName, LastName FROM your_database_name");
$results = $db->loadObjectList();


// Now, we need to convert the results into a readable RSForm! Pro format.
// The Items field will accept values in this format:
// value-to-be-stored|value-to-be-shown
// Eg. m|M-sized T-shirt
foreach ($results as $result) {
$value = $result->FirstName . ' ' . $value = $result->LastName;
$label = $result->FirstName . ' ' . $label = $result->LastName;
$items[] = $value .'|'. $label;
}


// Now we need to return the value to the field
return $items;
//</code>
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!