Save form data to multiple tables

How to update existing records in multiple database tables with ChronoForms.

Overview

The issue occurs when the form data array does not include the primary key values for the records to be updated, causing new rows to be inserted instead.
Ensure each DBSave action includes the correct primary key field from its respective table in the form data, such as 'id' for Joomla tables or 'cf_id' for custom CF tables, to target the existing records for update.

Answered
ca cachito 31 Aug, 2014
I made a form for updating a users profile. The data are read from two tables: the Joomla User table and a custom chronoforms-table with additional infos of the user. The data is hold under two differnt ModelIDs: User and UserExt.

After submitting the changed data i have two DBSave-Actions, one for the joomla table, one for the custom table.

My Problem: in both tables the data is not updated. After the Save-Action there is one new row in both tables.

What is my error?

Sorry for my bad english :-(

Greetings
Gerhard
ca cachito 31 Aug, 2014
Thank you calculus00,

but i read these faqs before and haen't find a solution.

Greetings
Gerhard
Max_admin Max_admin 01 Sep, 2014
1 Likes
Hi Gerhard,

Both models ids should have under them a field with the primary key value of each record, so in case of User, you must have a field named User[id]

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Gr GreyHead 01 Sep, 2014
Answer
1 Likes
Hi Gerhard,

To update a table you need to make sure that the $form->data array has an entry matching the Primary Key column of the record you want to update.

For a Joomla! table this will normally be $form->data['id']; for a ChronoForms created table it may be $form->data['cf_id']

Bob
ca cachito 01 Sep, 2014
Thank you Max, thank you Bob,

this was the hint i needed!

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