Forums

Editing a User's Record

vkeys 07 May, 2011
I've spent hours trying to get this working and I'm hoping someone can help me out here. I'm using the version 4 on Joomla 1.6.

Goal:
1) I want a form with four fields that saves to a database. It's only accessible for logged in users.
2) I want the user to send form to database as a new record, if one doesn't already exist for this user.
3) If a record already exists for this user, I want the form to populate with the database record (all four fields) for the logged in user.
4) I want the user to be able to edit or change the fields in the form and then save form, which then updates record in database. But not create a new record.

I've got the table setup and the form does save it to the table. But it creates a new record every time the user submits form. I don't know how to just modify an existing record.

Thank you for your help.๐Ÿ™‚
GreyHead 07 May, 2011
Hi vkeys,

Include the primary key value of the current record as a hidden input in your form.

Bob
vkeys 07 May, 2011
Hi Bob,

I'm not very bright on some things๐Ÿ˜‰

Should I add a 'hidden box' to my form and then add cf_id to the 'Field default value'?

Thank you,
Don
GreyHead 07 May, 2011
Hi Don,

Yes I think so - I've not done this in CFv4 yet.

Bob
vkeys 07 May, 2011
So far, to no avail.

I added {cf_id} to the 'Field default value' and when I hit submit, it just creates a new record. This form has On Load -> DB Record Loader and it loads the user's first record. But creates new ones๐Ÿ˜Ÿ

Attached are my settings for DB Record Loader. Can you help me with these? Maybe this is my problem.
Thanks,
Don
[attachment=1]Image1.jpg[/attachment]
[attachment=0]Image2.jpg[/attachment]
GreyHead 07 May, 2011
Hi vkeys,

Please try leaving the default value blank; and make sure that the input name is cf_id.

Bob
vkeys 07 May, 2011
Hi Bob,

I just did your suggestion and, unfortunately, it still creates a new record.

Field Id: cf_id
Field default value: blank
GreyHead 07 May, 2011
Hi vkeys,

And the field name is ???

Bob
vkeys 07 May, 2011
Hi Bob,

I finally got it. The field name is now cf_id. :mrgreen:

Thank you!
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger