Load CF standard database field user_id with logged in user

mburkart01 01 Mar, 2015
I found the tutorial, "How to store and load user's data". I added the PHP string to the DB Read action in the "On Load" event before the render action is called.

Here is the code I added to the condition field on the DB Read action from the tutorial.
<?php
$user = JFactory::getUser();
return array("user_id" => $user->get("id"));
?>
(I added the closing php)

According to the HowTo, I think all I needed to do was set "Enable Mode(l) ID" to No and copy the text above into the condition field.
[attachment=0]Screen Shot 2015-03-01 at 10.09.23 AM.png[/attachment]
[attachment=1]Screen Shot 2015-03-01 at 10.09.47 AM.png[/attachment]

On the form, I added a text field to show the "user_id" so I can verify the value, eventually I'll make it a hidden field. I make sure that I'm logged in and when I open the form, the "user_id" field id blank.

What am I missing?

thanks,
Mike
GreyHead 02 Mar, 2015
Answer
Hi Mike,

The obvious problem is that no table name is selected so the DB Read won't do anything.

Bob
mburkart01 02 Mar, 2015
Thanks Bob,

That was an easy fix.
This topic is locked and no more replies can be posted.