user_id not filled CFv5.03

octaviobh 27 Nov, 2014
Hi. As you can see in the images, I set the hidden user_id field to be filled with the joomla user id before the submit button, but the new record does not have the user_id field filled with it.
What can I do?.
Thanks in advance,
Octavio.

[attachment=0]user_id designer.JPG[/attachment]
[attachment=1]user_id designer edit.JPG[/attachment]
[attachment=2]user_id setup.JPG[/attachment]
[attachment=3]user_id setup edit.JPG[/attachment]
[attachment=4]user_id table.JPG[/attachment]
octaviobh 28 Nov, 2014
Please see the Form Name used in the image:

[attachment=0]user_id setup edit SOLVED.JPG[/attachment]
BNDragon 28 Nov, 2014
Hi Octavio,

To get joomla user you need to add a "&" so, set your code before HTML render action like this:

<?php
$user =& JFactory::getUser();
$form->data['id'] = $user->id;
?>


Then, on Load, your field will be filled.

BN
Max_admin 28 Nov, 2014
Hi,

If you have v5.0.3 then the user_id field should be filled in automatically if you don't have a "user_id" key in the data array, in other words, just remove your field and it will be stored if a user is logged in.

You can also use a "debugger" instead of "db save" to check the data array before its saved!

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
GreyHead 28 Nov, 2014
1 Likes
Hi BN,

The & is *not* required in Joomla! 3 - actually in PHP 5.3 and later I think - and may cause a PHP Warning or Notice.

Bob
BNDragon 01 Dec, 2014
Hi Bob,

I didn't know that. I'll be more careful now to try not use the "&" character🙂

Thanks,
BN
This topic is locked and no more replies can be posted.