Forums

Insert userdata alongside wizard designer

FenFire 03 Jun, 2014
Hello,
I recently startet to try out chronoforms and already understood a lot. But there are still some questions. I will post them in seperately.
For a prefilled form I tried to get some userdata (e.g. name) from the __users-table. I'm able to do this with custom code in the Code-Tab. The thing is, everytime I want to alter the form design with wizard designer, I have to switch in the Code-Tab, save and enter custom code again. So I tried to to this in the Setup-Tab ... and failed.

Details:
The onload area starts with a Custom Code event, containing: <?php $user =& JFactory::getUser(); ?>
After that I use DB Read. Here I put: Fields: name, Conditions: <?php return array("id" => "$user->id"); ?>

Notice: Undefined variable: user in C:\xampp\htdocs\joomla3\administrator\components\com_chronoforms5\chronoforms\actions\db_read\db_read.php(48) : eval()'d code on line 1

Notice: Trying to get property of non-object in C:\xampp\htdocs\joomla3\administrator\components\com_chronoforms5\chronoforms\actions\db_read\db_read.php(48) : eval()'d code on line 1

Notice: Undefined index: Data in C:\xampp\htdocs\joomla3\administrator\components\com_chronoforms5\chronoforms\actions\db_read\db_read.php on line 71


What have I done wrong?

Moreover, how exactly do I enter the read values in the forms. I've read distinct syntaxes. Is it Data[name] or Data.name? Do I have to put it in curly brackets?

Thanks in advance,
Christian
FenFire 03 Jun, 2014
Oh, I forgot: What is shown small and bold above are the hints I get when I open the form in the front-end, logged-in.
Max_admin 05 Jun, 2014
Answer
Hi Christian,

You just need a "db read" action before the "html" action with this code in the "Conditions":


<?php
$user = JFactory::getUser();
return array("id" => $user->get("id"));


Your form fields names should match the fields names in the users field, OR, if you enable the "read under model id" in the "db read" then your form fields names should include the model id as well:
Model[field_name]

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
FenFire 09 Jun, 2014
That's it?! So you can put more than just the conditions in the conditions field? You just have to create an array...
Thanks a lot!
GreyHead 09 Jun, 2014
Hi Christian,

Please see this FAQ about getting User info - it was written for CFv4 so may need a little adaptation to CFv5 but the main code should still work.

Please see this FAQ about building WHERE statements in CCv5 and CFv5.

Bob
This topic is locked and no more replies can be posted.