Buy Now
Sign in

How to import the database ID in a field in chronoforms v5?

Channelsupport , December 28 2017
Answered
C
Channelsupport
We use a registration form, made with Chronoforms v5. Applicants can enroll the form and we keep the results in our database. So far so good. Now, every form should have an unique number. Therefore we try to use the auto_increment field (ID) of the table from the database.
We don’t know how to import this ID in our form.

We use this php-code in a custom field of the form but no number appears:
<?php
// Get a db connection.
$db = JFactory::getDbo();

// Create a new query object.
$query = $db->getQuery(true);

$query->select('id');
$query->from($db->quoteName('aaa_datatable_SchoolAppFormXI'));
$query->where($db->quoteName('id')." = ".$db->quote($value));
$db->setQuery($query);
$result = $db->loadResult();
?>

Can someone give us advice about this?
GreyHead
Hi Channelsupport ,

If you are using the CF DB Save action to save the data then the new record ID is added to the $form->data array by ChronoForms - add a Debugger action temporarily to the form On Submit action so see where it is saved.

Bob

PS In your custom code it looks as if $value is not defined anywhere.
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
C
Channelsupport
Thanks for your reply.
We received similar information via a colleague.
The import of the ID-number in a field in chronoforms succeeded!

Channelsupport