Save last username that modifies data

Save the logged-in username to a database table when a form is submitted.

Overview

The form was not storing the username because the new database column was not properly mapped in the form's save action.
Enable the debugger to check the MySQL query and clear the CF cache. Alternatively, in CF v7, use the 'Data sources' setting in the Save Data action to map the new 'name' field to the {user:name} value.

Answered
ChronoForms v5
an angelmorales 29 Dec, 2020
Hello, well , I can retrive the username that its logged in, so I want to save that username to my table everytime the form its saved.

In the section On Load I put a Custome code with this:
<?php
$user =& JFactory::getUser();
$form->data['name'] =& $user->name;
?>
Then I put in the Designer a textbox (name) and the username displays there everytime the Form its loaded, everthing works fine so far.
Then I create a new column in my table= "name" so when the form its saved the username saves there.
But it doesnt work , form saves everything except the username😟

Please help!

Save last username that modifies data image 1


Save last username that modifies data image 2
Gr GreyHead 31 Dec, 2020
Hi angelmorales,

I suggest that you temporarily enable the Debugger in the form On Submit event so that you can see the MySQL query that is being created. That should help you diagnose the problem here.

Bob

PS You should also try clearing the ChronoForms cache if you have added a new column to the table.
Max_admin Max_admin 02 Jan, 2021
Answer
Easiest solution is to use v7 and in the "Save Data" action, use the "Data sources" advanced setting, then add a new table field "name" and set the value to {user:name}
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.