prepopulate form data from CB

cjmicro 04 Aug, 2008
I have Chrono Forms and Community Builder, and need the following:

1) Create from in Chrono Form (ok i can do this part!)
2) User is logged in with Community Builder, which is the default login for the site.
3) User goes to fill in form, and their CB profile info (name, email, phone, etc etc including custom fields) is already there on the form, prepopulated from the CB profile into the form. But they should be able to change it if they want too.

I have looked on the forums etc to see how to do this, and I can't seem to figure it out! I hope someone can help.

Thanks,
Cheryl
Max_admin 04 Aug, 2008
Hi Cheryl,

simply write an UPDATE SQL statement to do this when form is submitted, this is the only way!

Cheers

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
cjmicro 04 Aug, 2008
SIMPLY?? Easy for you to say. I have no idea how to do that, or how to get it to work :? And I don't want it to only submit the info, I want it to display it in the form, like in the "value" part of the field input area such as:

input type="text" name="name" value="name - grabbed from CB table based on user login" size="50"

While I'm at it is there any way the email of form submission that is returned can only display fields that have a value?

Thanks,

Cheryl
cjmicro 06 Aug, 2008
PS Another application I use, DT Register, has a plugin that fills in the registration forms with the info from their user record, including the custom fields.

So when you are logged in and you register for an event, the form fields are prepopulated with the information available from the user account.

I hope it makes sense what I'm trying to do. I wish I was more of a programmer, but I'm not, so I need help! ๐Ÿ˜ถ

Thanks for any assistance,
Cheryl
Max_admin 06 Aug, 2008
Hi Cheryl,

Go to your Chronoforms for, enable the Profile plugin, save, check your form then click the profile plugin link on the left side, configure it to the #__comprofiler table, fill in other fields, then back to your form and add {field_name} in all values attributes, read the profile plugin tooltips please and search teh forums here for profile plugin for the how to!

Cheers

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
cjmicro 06 Aug, 2008
Thank you Max, I will try this (and I did to some extent but wasn't having luck). I appreciate your taking the time to spell it out. Also, I have searched, but maybe not using the right terms.

Thanks again for steering me!! Wish me luck ๐Ÿ™‚

Cheryl
Max_admin 06 Aug, 2008
I wish you good luck๐Ÿ™‚
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
cjmicro 06 Aug, 2008
Ok, I got it to work, finding fields from CB. However, where is the email field? It doesn't seem to show on the CB table. Weird.

Thanks so much for helping this new user.

Cheryl
Max_admin 07 Aug, 2008
hi, get it with <?php global $my; echo $my->email; ?> assuming you have J1.0.x
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
cjmicro 07 Aug, 2008
Max, that did it, thanks!!

I tried the php echo, but didn't have the syntax exactly like yours, so this was the key.

Thank you SO MUCH.

Cheryl๐Ÿ˜€
deelstra 09 Aug, 2008

read the profile plugin tooltips


There are no tooltips yet?
I also see the table name list to choose from. I do not see such a list for the CB registation plugin, is that right?
Max_admin 09 Aug, 2008
Hi deelstra,

tell me the problems you are facing exactly and I will try to write some tutorial for you and all users today!

Cheers

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
cjmicro 18 Aug, 2008

Go to your Chronoforms for, enable the Profile plugin, save, check your form then click the profile plugin link on the left side, configure it to the #__comprofiler table, fill in other fields, then back to your form and add {field_name} in all values attributes, read the profile plugin tooltips please and search teh forums here for profile plugin for the how to!



I am an idiot Max. I had a test form that was working with this, and deleted it since I figured out how to do it. But now I'm drawing a blank, I know where to put the value="{fieldname}" but I can't remember what to put in the plugin fields.

tablename=jos_comprofiler
request param= DUH-- brain fart on my part..... what goes here?
target field name= username (DUH again but I think this is right?)

Can you let me know, and I won't delete the working test this time. Sorry ๐Ÿ˜ถ

Cheryl
Max_admin 18 Aug, 2008
Hi Cheryl, target field I think is id or user_id
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
cjmicro 19 Aug, 2008
what about the request param? that's the one i'm clueless on.

Cheryl
Max_admin 19 Aug, 2008
I don't think you will need this one, it will get the logged in user id auto.
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
cjmicro 19 Aug, 2008
Ok, got it!! My brain fart was using the field names from the FORM not the field name from the database on the plugin config, and then I had to remember to go to the plugin tab in the form edit and check the plugin (duh).

But the best part is that I also figured out how to use the info in the profile on the form in a drop down option. I'll post it here in case anyone else is interested.

<input type="text" name="first" size="20" value="{firstname}"></p>
<p>Last Name:ย 
<input type="text" name="last" size="20" value="{lastname}"></p> 
<p>Child:ย  <select size="1" name="D1">
<option>{cb_childfname}</option>
<option>{cb_childnameb}</option>
<option>{cb_childnamec}</option>
<option>{cb_childnamed}</option>
</select></p> 
<p><input type="submit" value="Submit" name="B1" "><input type="reset" value="Reset" name="B2"></p>


It picks the fields with values and adds them to the drop down. If there is no value (like no childnamec or childnamed) it just leaves it blank. ๐Ÿ˜€

It will also allow me to put more than one field in the value, like
value="{first name} {last name}"


I'm sure you guys already know this since you wrote the stuff, but I feel pretty darn smart right about now. :wink:

Probably seems simple to some, but I was very excited as this is a MAJOR function the client needs on the site and it's simple with the plugin (once you remember all the steps ๐Ÿ™„ ).

THANK YOU Max & Bob for all your help.
thatsus 19 Aug, 2008
Thank you for this thread. It's been very helpful so far.
I've been able to prepopulate a contact form using the methods you describe here, but I am wondering if there is any way not to have the value of a field display {fieldname} if the user is not logged in. What I mean is: Using the method here, a logged in user will see his first name in the appropriate textbox, but a user who isn't logged in will see {firstname} in the same textbox.
Max_admin 19 Aug, 2008
well, at the top of the form code write something like :

<?php
$my = JFactory::getUser();
if(!$my->id){
echo "you are not logged in";
return;
?>
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
cjmicro 25 Aug, 2008
Hello Max,

Thank you for this info. I, too, would like to not display the {fieldname} in the value of the field if they are not logged in. You provided this:

<?php
$my = JFactory::getUser();
if(!$my->id){
echo "you are not logged in";
return;
?>



I tried it and I get a syntax error.

Parse error: syntax error, unexpected $end in /home/crptou/public_html/components/com_chronocontact/chronocontact.html.php(74) : eval()'d code on line 28



Meanwhile, I noticed that the php echo you gave me earlier for the email does not show the {fieldname} in the text area, nor does the name (which I figured out how to do with the php echo as well!!)

<?php global $my; echo $my->email; ?>  or <?php global $my; echo $my->name; ?> 


Is there a php echo statement we could use for the value of the field instead of the {fieldname}? I have tried replacing the email or name with the fieldname: for example <?php global $my; echo $my->phone; ?> , where phone is the fieldname I want, but that's not doing it.

Or can you help me get the original php statement you posted to work? Thank you!

Cheryl
GreyHead 25 Aug, 2008
Hi Cheryl,

The first code block is missing a closing } - that's what gives you the error message.
<?php
$my = JFactory::getUser();
if ( !$my->id ) {
    echo "you are not logged in";
    return;
}
?>


Textarea doesn't take a value attribute, you can put the value between the tags instead. Not tested but this should work:
<textarea name="field_name"  . . . >{field_name}</textarea>


Bob
cjmicro 26 Aug, 2008
Hi Bob, and thanks for the reply,

I'll try the new code (I told you I wasn't a programmer!! There is not enough vodka in the world for me to keep track of all those squiggly lines and symbols... ๐Ÿคฃ )

Textarea doesn't take a value attribute, you can put the value between the tags instead. Not tested but this should work:

Code: Select all
<textarea name="field_name" . . . >{field_name}</textarea>



It's not a text area, just a text field. Sorry if I didn't make that clear. But that might come in handy as well someday!!

Cheryl
chakatz 28 Aug, 2008

hi, get it with <?php global $my; echo $my->email; ?> assuming you have J1.0.x



How would this be done in J1.5.x?

Thanks.
Max_admin 28 Aug, 2008
<?php
$my = JFactory::getUser();
echo $my->email;
?>
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
kavaXtreme 13 Sep, 2008
This is very awesome! Cheryl, thanks for your brain farts.๐Ÿ˜€ Max and Bob, thanks for your collective wisdom! This should really be in a tutorial somewhere.

I set out to do this, didn't quite get it from the faq, and then found this thread which worked like a charm. I still have one issue though. Some forms need to be visible to both public and registered users, but I'd still like to let the registered users have the perk of having the form prepopulated, while public users would just see a regular blank form (rather than disabling the form entirely).

This concept seems to work for me (with $my = JFactory::getUser() at the top of the form):

<?php if ($my->id) echo "{fieldname}" ?>

But is there a way to do that more efficiently? It seems like there must be a way of just checking once if a user is logged in and if not ignoring any plugin values, but I'm with Cheryl having brain farts on this one (and also not a programmer).
Max_admin 14 Sep, 2008
Hi,

more efficiently then wait for the next release, I think I will solve that issue permanently, every form record will be assigned to the user submitted it too, forms will have access permissions and more control.

Regards

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
kavaXtreme 14 Sep, 2008
Sounds good. ChronoForms is already the best Joomla forms component I've used, so it'll be cool to see what changes you have planned.
staffiery 04 Oct, 2008
I'm using 1.0.15 with CB 1.2.3 when I use
    <?php if ($my->id) echo "{fieldname}" ?>
in my CF form it is being stripped out when the form is published...I'm trying to get the CB registration data to populate the fields in CF I've setup the CB Registration plugin to reference the correct fields, but that appears to allow the CF form to update CB not the other way around...or am I missing something? Thanks in advance for any help.
kavaXtreme 05 Oct, 2008
Did you include the following at the top of the form?:

$my = JFactory::getUser();
Max_admin 05 Oct, 2008
Hi staffiery,

as kavaXtreme mentinoned, this line is necessary, also, if you are trying to populate a form fields with some data using Chronoforms, you should make a form and assign the profile plugin to it, after configuring the profile plugin and using the formula you have, the form will load the data from some table!

Cheers

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
GreyHead 05 Oct, 2008
Hi staffiery.

Just to correct kavaXtreme's post - in Joomla 1.10.15 you need
<?php
global $my;
?>
somewhere before you use $my; the JFactory code is for Joomla 1.5.x.

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