I am trying to save data to two tables which need to be related. I have read and tried the suggestions from an earlier post (Save form data into 2 tables, posted August 17, 2019 ) many times. But I guess I am missing something.
I am able to save data to the first table, which is the Joomla users table. I want to then use the id from that table and save it to another table so I can relate the two tables.
So I save the user data from a form. The model name for the user file is Users.
Then I read the user file as follows:
Name is read_users_id
Model is Users
Select type is First Matching record
Order is id, descending
Fields to retrieve is Users.id
According to the debug, the Users.id is retrieved successfully.
Then to save to the second table:
Name: read_info
Database table: newuserinfo
Write Action: Insert
Data Provider: {var:read_users_id#.Users.id}
Model: Users
I have tried using Data Override using the name of the field in the second table and specifying what I want to to be set to
Set userfile_id to {var:read_data#.Users.id} on insert
I have also tried to set a condition: userfile_id = Users.id
Apparently I am not using the correct syntax for the data I want to pass because am not getting a value for userfile_id.
Also, the primary key of the receiving table is aid and it is not being auto incremented.
So two issues, how can I get the correct value in the userfile_id field of the receiving table ?
And how can I cause the aid to be auto incremented?
Thanks for your help.
Karen
I am able to save data to the first table, which is the Joomla users table. I want to then use the id from that table and save it to another table so I can relate the two tables.
So I save the user data from a form. The model name for the user file is Users.
Then I read the user file as follows:
Name is read_users_id
Model is Users
Select type is First Matching record
Order is id, descending
Fields to retrieve is Users.id
According to the debug, the Users.id is retrieved successfully.
Then to save to the second table:
Name: read_info
Database table: newuserinfo
Write Action: Insert
Data Provider: {var:read_users_id#.Users.id}
Model: Users
I have tried using Data Override using the name of the field in the second table and specifying what I want to to be set to
Set userfile_id to {var:read_data#.Users.id} on insert
I have also tried to set a condition: userfile_id = Users.id
Apparently I am not using the correct syntax for the data I want to pass because am not getting a value for userfile_id.
Also, the primary key of the receiving table is aid and it is not being auto incremented.
So two issues, how can I get the correct value in the userfile_id field of the receiving table ?
And how can I cause the aid to be auto incremented?
Thanks for your help.
Karen