set a variable on "fields" of db_read or xls_export action

How to dynamically set fields for database reads or Excel exports in ChronoForms.

Overview

The issue occurs when needing to generate Excel files with variable field selections based on user input, which isn't directly supported in the action configurations.
Use custom PHP code to define a variable containing the desired field names and integrate it into your SQL query before passing the results to the export action.

Answered
teldrive teldrive 04 Jun, 2014
I apreciate if someone can help, i'm not sure if it's implemented on CFv5 but i think is worth to do it , may be you can suggest me any workaround
The issue is to be able of generate excel files truncating some fields depending of user selection
the idea is to have a variable as {fieldsvar} you can concatenate different fields depending of customer selection
$form->data['fieldsvar']= "id,nombre,ratem";

and after apply it into db_read action or xls_export action
[attachment=0]Captura.JPG[/attachment]

we also are using "conditions" field of db_read to link submit_selectors of CC_list to this Excel_export form
<?php
return  array("id" => $form->data['gcb']);
?>
teldrive teldrive 05 Jun, 2014
Answer
I 've got it with custom code, but anyway I think could be interesting to add it in db_read action

$form->data['fieldsvar'] ="`id`,`titulo`";
$db =& JFactory::getDBO();
$query = "
     SELECT {$form->data['fieldsvar']}
         FROM `#__paper_form`
          WHERE `id` IN ({$form->data['vals']});
 ";
 $db->setQuery($query);
 $form->data['paper'] = $db->loadAssocList();
?>
teldrive teldrive 05 Jun, 2014
I'd like to comment that also include this possibility into xls_export action will do posible rename fields dinamically
This topic is locked and no more replies can be posted.