• 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: How can I populate a list item?

How can I populate a list item? 2 years 11 months ago #41096

  • Crispin
  • Crispin's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 73
  • Thank you received: 4
How can I populate a list item from submitted items?

I want to simplify adding items to the list as these will change and I need my client to be able to update as they go along.
The administrator has disabled public write access.

How can I populate a list item? 2 years 11 months ago #41103

  • andreic
  • andreic's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 713
  • Thank you received: 59
Hello,

If I understand correctly you want to generate a list of items from one of your database tables. Please refer to the following article for an example:
www.rsjoomla.com/support/documentation/r...st-from-a-table.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.

How can I populate a list item? 2 years 11 months ago #41144

  • Crispin
  • Crispin's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 73
  • Thank you received: 4
Apologies for the delayed response.

Thank you for providing this link. I will experiment and feed back how I get on.

Thank you
The administrator has disabled public write access.

How can I populate a list item? 2 years 11 months ago #41148

  • Crispin
  • Crispin's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 73
  • Thank you received: 4
As there are other forms on the website if I use this as is it tries to load everything from the Table column identified, 'FieldValue'.

How can I select values from a specific field from a particular form?

Thanks for your help on this
The administrator has disabled public write access.

How can I populate a list item? 2 years 11 months ago #41151

  • Crispin
  • Crispin's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 73
  • Thank you received: 4
I have tried to cobble together this

In the first form
if(session_id() == '') {
    session_start();
}
$_SESSION['form_add_vacancy'] = $SubmissionId;

In the form which I want to populate the list item from the VacancyTitle field of the first
//<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
$sql = "Select FieldValue from ch2rx_rsform_submission_values WHERE SubmissionId=".$_SESSION['form_add_vacancy']." AND FieldName='VacancyTitle';";
$db->setQuery($sql);
$result = $db->loadResult();
 
// 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 ($result as $result) {
  $label = $result->VacancyTitle;
  $items[ ] = $label;
}
 
// Multiple values are separated by new lines, so we need to do this now
$items = implode("\n", $items);
 
// Now we need to return the value to the field
return $items;
//</code>

The good news, there are no errors, the bad news no items appearing either.
The administrator has disabled public write access.

How can I populate a list item? 2 years 11 months ago #41152

  • Crispin
  • Crispin's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 73
  • Thank you received: 4
I got it working and this is the final code added to the items field on my dropdown.
//<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 FieldValue FROM ch2rx_rsform_submission_values WHERE FieldName='VacancyTitle'");
$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->FieldValue;
  $label = $result->FieldValue;
  $items[] = $value.'|'.$label;
}
 
// Multiple values are separated by new lines, so we need to do this now
$items = implode("\n", $items);
 
// 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!