I thought I had this figured out . I had an earlier post on December 3, which was answered. However obviously I am losing it because I can't get this to work.
I am trying to save data to two tables - the Joomla user table and another table which is related.
I have a list which successfully displays data from both tables and I am able to call up a form, edit information in both tables and successfully save to both tables.
However I am not able to add records to both tables. The tables are related as follows:
First model is Info with table newuserinfo . The second model is Users (Joomla users table) and is related to Info where Relation is "One matching record, foreign key at the related table." The foreign key is userfile_id in the Info table.
I call up a form which has the text boxes for the pertinent information for both tables.
The save event is
{fn:save_core_user_info}
{fn:check_added_user_save_result}
{fn:save_info}
{fn:check_added_contact_save_result}.
The save_core_user_info uses the Save User action and is successful.
But the save_info action is not successful in that it saves to the table but the userfile_id is zero and there is no other data.
My save_info action parameters look like this:
Database table: newuserinfo
Write action: Insert
Data provider: {var:save_core_user_info.Users.id}
Model: Info
For overrides I have:

Where am I going wrong?
I am trying to save data to two tables - the Joomla user table and another table which is related.
I have a list which successfully displays data from both tables and I am able to call up a form, edit information in both tables and successfully save to both tables.
However I am not able to add records to both tables. The tables are related as follows:
First model is Info with table newuserinfo . The second model is Users (Joomla users table) and is related to Info where Relation is "One matching record, foreign key at the related table." The foreign key is userfile_id in the Info table.
I call up a form which has the text boxes for the pertinent information for both tables.
The save event is
{fn:save_core_user_info}
{fn:check_added_user_save_result}
{fn:save_info}
{fn:check_added_contact_save_result}.
The save_core_user_info uses the Save User action and is successful.
But the save_info action is not successful in that it saves to the table but the userfile_id is zero and there is no other data.
My save_info action parameters look like this:
Database table: newuserinfo
Write action: Insert
Data provider: {var:save_core_user_info.Users.id}
Model: Info
For overrides I have:
Where am I going wrong?
Hi kkurtz,
I suggest that you turn the Debugger on so that you can see the MySQL queries that are being generated. That should let you pin down the error.
I assume that this is a ChronoForms query and not ChronoConnectivity?
Bob
I suggest that you turn the Debugger on so that you can see the MySQL queries that are being generated. That should let you pin down the error.
I assume that this is a ChronoForms query and not ChronoConnectivity?
Bob
Shouldn't it be {var:save_core_user_info.Users.id} ?
I tried that again both in the data provider and override fields and I get this message [h2]#1048 Column 'userfile_id' cannot be null[/h2]
I have a debugger in the event but it doesn't get to that only the message above.
I have a debugger in the event but it doesn't get to that only the message above.
One more thing. In a prior test I put a debugger after the user file save and it is returning the id from the user file. That save is successful.
Hi,
Please open the table in phpmyadmin and enable the NULL flag for all fields except the primary keys in order to avoid the error!
2nd, use the debugger to check which data was actually saved to the table, is {var:save_core_user_info.Users.id} a valid value you have already ?
Best regards
Please open the table in phpmyadmin and enable the NULL flag for all fields except the primary keys in order to avoid the error!
2nd, use the debugger to check which data was actually saved to the table, is {var:save_core_user_info.Users.id} a valid value you have already ?
Best regards
Max,
I have changed phpmyadmin as you suggested.
On the second issue I am not exactly sure what you are asking. Here is the debugger output.
I have changed phpmyadmin as you suggested.
On the second issue I am not exactly sure what you are asking. Here is the debugger output.
Array
(
[save_core_user_info] => Array
(
[_success] => User saved successfully under id 121
[var] => Array
(
[name] => Ninety Six
[username] => 969696
[email] => ninety6@somewhere.com
[password] => nsix
[block] => 0
[activation] => 0
[registerDate] => 2019-12-17 17:54:51
[id] => 121
)
)
[check_added_user_save_result] => Array
(
[finished] => 1
[var] =>
)
[save_new_info] => Array
(
[data] => Array
(
[firstname] => Ninety
[lastname] => Six
[homeclub] => Soule Park
[officerclub] => Birch Hills
[member] => y
[president] =>
[delegate] =>
[handicap] =>
[membership] =>
[board] =>
[userfile_id] =>
[created] => 2019-12-17 17:54:51
[user_id] => 23
)
[_success] => Data saved successfully
[log] => Array
(
[0] => INSERT INTO `newuserinfo` (`firstname`, `lastname`, `homeclub`, `officerclub`, `member`, `president`, `delegate`, `handicap`, `membership`, `board`, `userfile_id`, `created`, `user_id`) values ('Ninety', 'Six', 'Soule Park', 'Birch Hills', 'y', '', '', '', '', '', ' ', '2019-12-17 17:54:51', '23');
)
[var] => Array
(
[firstname] => Ninety
[lastname] => Six
[homeclub] => Soule Park
[officerclub] => Birch Hills
[member] => y
[president] =>
[delegate] =>
[handicap] =>
[membership] =>
[board] =>
[userfile_id] =>
[created] => 2019-12-17 17:54:51
[user_id] => 23
[aid] => 1269
)
)
[check_added_contact_save_result] => Array
(
[finished] => 1
[var] =>
)
)
I mean the "userfile_id" value is empty, where are you trying to get its value from ?
I am using a form to add data to two tables. The form contains fields for both tables - the Joomla user table (Users) and a related table (Info). The tables are related by Users.id and Info.userfile_id. So I save the data to the user table first and then to the Info table. I want the Info.usersfile_id to equal the Users.id. As you can see in the debugger above the id in the Users table is being saved but is not being passed to the Info table.
Karen
Karen
I should mention that I am using the "old" form view fields as I just modified an existing form.
Hi,
According to the debug data, the path to the saved user id should be:
Best regards
According to the debug data, the path to the saved user id should be:
{var:save_core_user_info.id}if this code is used after the user is saved, it should contain the user's id!
Best regards
This topic is locked and no more replies can be posted.