Use logged in user ID to open record in a form

momentis 24 Feb, 2012
I have a table in my database called "gra_acct_info". This table contains a field named 'acct_user_id', which matches the 'id' field in the Joomla "users" table.

How can I create a form that will open, pulling in the data from "gra_acct_info" for the currently logged-in user?

I have tried to follow along with the PDF "How to load one row from a DB into your form", but I admit that I am missing something!!

Thanks!
Rick
GreyHead 24 Feb, 2012
Hi Rickm

What do you have in the DB Record Loader settings now? And what do you see if you add a Debugger action to the On Load event.

Bob
momentis 24 Feb, 2012
I have the following--

DB Field: acct_user_id
Table: an8ke_gra_acct_info
Load Fields: Yes
Curly Replacer: Yes
Load Under Model ID: No
Where Statement:
<?php 
$user =& JFactory::getUser();
echo "`acct_user_id` = '{$user->id}'";
?>


With a debugger action, I see this:
Data Array:
Array
(
    [option] => com_chronoforms
    [chronoform] => edit_acct_info
    [Itemid] => 
    [acct_id] => 36
    [acct_user_id] => 47
    [acct_name] => ABC Heating and Cooling
    [acct_address] => 105 Main Street
    [acct_city] => Cleveland
    [acct_state_short] => OH
    [acct_zip] => 96841
    [acct_phone] => 800-555-1212
    [acct_fax] => 800-555-4819
    [acct_principal] => Sam Asher
    [acct_quota_purch] => 85000.00
    [acct_quota_points] => 2500
    [acct_todate_purch] => 42025.00
    [acct_todate_points] => 1131
    [acct_last_update] => 02/01/2012
)

Debug Data

    db_record_loader
        SELECT * FROM `an8ke_gra_acct_info` AS `An8keGraAcctInfo` WHERE `acct_user_id` = '47'


Interestingly enough, that is the correct information. I create most of my forms using the Easy Form Wizard. This one, due to my needs, I am building under the regular Form Wizard. I am trying another form under the Form Wizard as well (without an OnLoad action) and neither one will display on the front end of the site.
momentis 24 Feb, 2012
Geez, sorry about that, Bob!! I am only now getting into more involved forms, so I guess I should RTFM!!!

BTW - Are you accepting custom jobs? I only have so much time to do this stuff, and I may be better served to pay an expert!! Let me know. 😀
This topic is locked and no more replies can be posted.