How to get id of record in form and put iin url on On Submit

peterswa62 22 Oct, 2012
Hi. I have a form called ViewClient. I want a button called Edit where by when you click it it goes to another Form from called EditClient so you can edit the data for that record. To do this I need to get the primary key:- id in the ViewClient and a query string using a custom code block to re-direct it on the On Submit Action like this:-

<?php
header('Location: http://www.dcaccountancyservices.com/index.php?option=com_chronoforms&tmpl=component&chronoform=ViewClient&token2=' . $client['id']);
?>

I have a model called client in DB Record Loader so referencing $client['id'] should get the id to put in the url. Instead all I get is $client['id'] is empty of any value. What am I doing wrong or is there a better way of doing this?
GreyHead 22 Oct, 2012
Hi peterswa62,

Have you tried adding a Debugger action to see what values you actually have? I suspect that $client['id'] is empty.

Bob
peterswa62 22 Oct, 2012
Done that the Debugger shows the correct value of id but when I put:- echo $client[id], instead of showing the value it just shows:- $client[id]. When you put code in a custom code block is it still inside the form?
GreyHead 23 Oct, 2012
Hi peterswa62,

Yes, Custom Code is still inside the form, or at least a Custom Element element is. Outputting from a Custom code action may not be inside the form depending on the timing and settings. It's best to add any calculated data to the $form->data array and output it in a form element either as a value or using {} or PHP in a Custom Element element.

Bob
This topic is locked and no more replies can be posted.