• 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: Hack to display caption instead of field name

Hack to display caption instead of field name 13 years 1 month ago #16881

  • royce
  • royce's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 52
  • Thank you received: 5
We have almost 10,000 users uploading numerous forms all day long! Our customer support folks have to export the data to perform validations etc. Our form data is also stored in internal and external databases. The form fields have generic names for the fields (e.g. f1, f2, f3) and descriptive captions (e.g. How old are you, When were you born, etc.).

The problem was that when the CSR's export the data, the spreadsheet would have the field names (f1, f2, etc) as the column headers instead of the user friendly captions. For a while they had to manually cut and paste the captions into the spreadsheet headers.

I asked RSFP if the export could use the caption instead of the names, but they said that the software didn't support that.

Here is a hack I used to fix this issue. In administrator/components/com_rsform/controllers/submissions.php around line 267 (in the excel export clause) I put:
if ($start == 0 && $use_headers) {
	// RSH 3/26/12 Convert name to caption for headers
	$xls->write_headers($this->convertNamesToCaptions($order, $formId));
}

I then added the following function:
// RSH 3/26/12 Convert name to caption for headers
function convertNamesToCaptions($names, $formId)
{
	$result = array();
 
	if (is_array($names)) {
 
		foreach ($names AS $index => $name)
		{
			$query = 'SELECT `p1`.`PropertyValue`'
				. ' FROM `#__rsform_properties` AS p1,'
				. ' `#__rsform_properties` AS p2'
				. ' WHERE `p1`.`ComponentId` = `p2`.`ComponentId`'
				. ' AND `p2`.`PropertyName` = "NAME"'
				. ' AND `p1`.`PropertyName` = "CAPTION"'
				. ' AND `p2`.`PropertyValue` = "' . $name . '"'
				. 'AND `p1`.`ComponentId` IN (SELECT `ComponentId` FROM `#__rsform_components` WHERE `FormId` = ' . (int) $formId . ')'
				. ';'
				;
 
			$this->_db->setQuery($query);
			$caption = $this->_db->loadResult();
			$result[] = ($caption) ? $caption : $name;  // Use the name if nothing found - this puts a header on hidden fields, etc.
			unset($query);
		}
 
	} else {
		$result = $names; // send it back??
	}
 
	return $result;
}

This may help someone else.
Last Edit: 13 years 1 month ago by royce. Reason: code fix!
The administrator has disabled public write access.
The following user(s) said Thank You: webcat-solutions

Hack to display caption instead of field name 10 years 10 months ago #27936

  • biuro3
  • biuro3's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
It seems not working in RSForm! Pro 1.49.11.
Could anybody review it and update in orderto make it work?
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!