How to update a record when I resubmit the form

am_soumya 30 Dec, 2012
Hi,

I have multipage form with 4 pages. I am using dbsave action for saving the inserted data to db. But when I jump to next page and click on save and continue button to jump to next page, it is duplicating the record in db. I want to update the data instead of inserting it as a new record. What should i do for it???


Thanks and Regards,
Soumya
GreyHead 31 Dec, 2012
Hi Soumya,

After the first DB Save you need to get the new record ID and add this to your form in a hidden input; then the following saves will update the same record and not create a new one.

Assuming that the primary key of your table is 'cf_id' then add this to a Custom Code action after the first DB Save
<?php
$form->data['cf_id'] = $form->data['chronoform_data_cf_id'];
?>
and add a hidden input to the remaining forms with the name cf_id

Bob
am_soumya 02 Jan, 2013
Thank you !!!!!!!!! it worked...
This topic is locked and no more replies can be posted.