Forums

Passing a parameter from CF5 back to CC5?

bon-ja-mon 12 Apr, 2016
Hi

Along the same vein as a previous post of mine http://www.chronoengine.com/forums/posts/f2/t101596/how-do-i-return-to-a-joomla-page-after-saving-a-cf-form-from-a-cc-table.html I have a question.

I have a CC5 that uses a URL parameter in the Conditions box to filter the list that is displayed using the following:

<?php
    $dept = JRequest::getString('userid', '', 'get');
    return array('user_id' => $dept);
?>


So if I load the CC5 with
?userid=180
at the end of the URL the CC5 only displays rows which match user_id=180. This is all working fine.

My issue comes when I link from this CC5 to a CF5 to edit the data. I have a Connection Action on the On Submit action which saves the form data and sends me back to the CC5, however I cant see how I can pass a URL parameter back to the CC5 from the CF5. I am using model IDs. Without it, the CC5 doesnt show the filtered list it showed before I clicked through to the CF5.

I have tried changing the Connection Action for a DB Save and Redirect Action (as this action can handle the URL parameters), but this set up errors with the message:

Fatal error: Cannot redeclare class GCore\Models\expenses in /var/sites/t/XXX/public_html/administrator/components/com_chronoforms5/chronoforms/actions/db_save/db_save.php(73) : eval()'d code on line 4


Any assistance on how to pass back to the CC5 a URL parameter once I have saved the CF5 would be appreciated.

Thanks
GreyHead 12 Apr, 2016
Hi bon-ja-mon,

You can do that by saving the data to the User Session. IIRC, CC has a setting to do that, you can re-read and delete it on return.

Bob
bon-ja-mon 12 Apr, 2016
Hi Bob

Thanks for the reply. I dont know how I would load the User Session data from CC on returning to it from CF. If you could point me to how you think I could achieve calling some of the data to the Conditions box that would be great.

Kind regards
GreyHead 13 Apr, 2016
Hi bon-ja-mon,

I'm travelling this week so writing this from memory. The code for reading/writing to the session is:

<?php
$jsession = \JFactory::getSession();
$jsession->set('name', 'value');
$jsession->get('name', 'default');
?>

Bob
bon-ja-mon 03 May, 2016
Hi Bob

Sorry it has taken a while to come back. In the end we kept with the DB Save and Redirect actions, however to get the DB Save to work we simply dropped the variables from the model ID before doing the DB Save.

So to help anyone else I used a Custom Code before the DB Save with lines like this:

$form->data['modelidhere']['field1'] = $form->data['filed1']


The DB Save was then set up without the model ID and the save and Redirect both work.

Cheers
bon-ja-mon 03 May, 2016
Just realised I put a typo. The code should have been:

$form->data['field1'] = $form->data['modelidhere']['filed1']
This topic is locked and no more replies can be posted.