Forums

Can get the records to update on submit.

dsmith152 04 Jun, 2015
I'm having the toughest time time trying to figure this out. I have a simple form that I want to collect logged in user information. I also want to have the ability for the user to update their info as needed.

Under the current setup is creates a new record on submit. It doesn't update the record. And on db read it reads the first record. So any updates made are saving to a new record. Any help would be greatly appreciated!

I just loaded the current version of Chronoforms this morning.

My Form Fields are as follows:

id, uniq_id, user_id, created, modified, facebookusername, fbpw, twitterusername, twitterpassword, linkedinusername, and linkedinpassword.

DB Read Info as follows:

Action Label: Blank

Enabled: Yes

Table name: mpm_CF_CMG_Collect_Social_Info

Multi read: No

Enable Model ID: no

Model ID: No

Fields: facebookusername, fbpw, password16, twitterusername, twitterpassword, linkedinusername, linkedinpassword, user_id, id

Order: Blank

Group: Blank

Conditions: Blank

DB Save Info as follows:

Action Label: Blank

Enabled: Yes

Table name: mpm_CF_CMG_Collect_Social_Info

Save under Model ID: No

Multi save: No

Model ID: Blank

Force save: No

Update conditions: Blank

Below is a screen shot of the setup:
dsmith152 10 Jun, 2015
I think I'm trying to over complicate this process. I have read through the faq above and I added the code below to the db read "conditions" box:

<?php
$user = JFactory::getUser();
return array('user_id' => $user->id);
?>


I can go in and enter and update information for a user (user1) and all works great, and when I login as a different user (user2) I can do the same. The problem is when I go back to user 1 I can enter the info and it will save to a record, but if I go back to the form and try to update again the latest it doesn't display the latest record. It displays the last record entered before I entered information for user2.

I have a feeling that I am still missing something because its not updating the records its adding a new every time. For example every time I make an update to user1's info i get new record. User1 has about 10 records. It seems that I should only have one for each user.


FYI: This form is just for logged in users.
GreyHead 11 Jun, 2015
Hi dsmith152,

Please check the Saving an Updated Record section in the FAQ, it sounds as though you are not saving the record id so a new record is being created each time.

Bob
jmahun 27 Jul, 2015
I'm using a connection to show a records list from my table. The cf_id field is used as the Viewable link to open a form. The form has a DB read action and loads the correct record. The form also has a DB Save action so the user can edit the record and save it.
Problem is, it gets saved as a new record rather than updating the old one. I have the cf_id field display in a Disabled field on the form so I can see it's the correct record.

I searched the FAQ for Saving an Updated record as you suggested, but couldn't find anything that helped. Your comment "sounds as though you are not saving the record id so a new record is being created each time" has me confused. How do I "save the record id" so the record is updated instead of a new one being added?
GreyHead 27 Jul, 2015
Hi jmahun,

Please put the cf_id in a readonly input - disabled inputs are not submitted so the value is lost.

Bob
jmahun 27 Jul, 2015
Thanks, that did it.
Jerry
This topic is locked and no more replies can be posted.