Forums

[SOLVED] Auto Fill - DB Record Loader

mduda 04 Aug, 2012
I am very "green" to chronoforms. But, after days of trying to figure this out (reviewed tutorials and scoured forums), am willing to buy two beers for any assistance! 😀

I'm trying to pull fields from the registration table (CF registration). In the preview pane, I have the field name proper labeled lastname (for example). However, when I go to the form, nothing is populating. I'm sure I'm missing something, but since I'm on v4 I'm having difficulty finding more examples in the forum.

What am I missing? I really appreciate your help!
Max_admin 04 Aug, 2012
Hi,

Your configuration looks fine, but in order for this action to load data, you will have to pass a valid record cf_uid under a parameter called "token".

e.g: index.php?option=com_chronoforms&chronoform=dynamic_dropdown&token=111111111113123213123213

Are you doing this correctly ?

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
GreyHead 04 Aug, 2012
Hi mduda ,

Please try adding this code into a Custom Code action before the DB Record loader:
<?php
$user=& JFactory::getUser();
$form->data['token'] = $user->id;
?>
Note using 'token' here is arbitrary - you can use any label provided that it matches the entry in the Request Params box of the DB Record Loader action.

Bob
mduda 05 Aug, 2012
GH - with your clarification on the "token", I was able to get it to work! Thanks! However, I'm unclear on where the data is actually being pulled from. The table is a registration form created in CF. I have the name field broken up - "lastname" and "firstname". But, I'm unable to pull either of these from the table. I am able to pull "name" - since Joomla uses "name", I have to assume that it's pulling from the joomla user table? Any ideas on how I can get the actual fields from the CF Registration form?

Thank so much!
GreyHead 05 Aug, 2012
Hi mduda,

The DB Record Loader will load data from whatever table you have in the settings. Use a Debugger action to see exactly what is there.

The two lines of code I posted get the Joomla! User Object which does come from the jos_user table. But you only need the User ID from that to identify the correct record in your table.

Bob
mduda 07 Aug, 2012
I still don't have it! Ugh. Let me post what I have, and please tell me in layman's terms what I'm missing. I truly appreciate your time! (and patience🙂
[attachment=1]cfcode.png[/attachment]
[attachment=2]cfload.png[/attachment]
[attachment=0]cf.png[/attachment]
GreyHead 07 Aug, 2012
Hi mduda,

I'm sorry, there was a typo in the code I posted :-)

$user_id should be $user->id
I fixed my original post

In your images:

1) the mode should be 'controller' instead of 'view'

2) I find it a bit odd that your call the 'user ID' parameter 'email' but it will work OK as long as you are consistent.

Bob
mduda 07 Aug, 2012
GH - thanks for getting back to me so quickly. I'm ready to pull my hair out😟 I can not figure out what I'm doing wrong here.

I changed the view to controller and adjusted the custom code. The fields are not populating on the form.
mduda 07 Aug, 2012
Got it!!! Thank you so much!!! Will buy you two beers when I wake up tomorrow am!
KarelMG 13 Sep, 2012
After some trial & errors I've got my form correctly reloaded with the original data filled in.
Unfortunately when I change any data and hit the submit button the old record is not overwritten, but a new record is made.😟 How do I get the old record data revised🤨
GreyHead 14 Sep, 2012
Hi KarelMG ,

You need to make sure that the primary key value for the record that you want to update is included in the form data. Usually you'd do this by including it in a hidden input in the form. For example:
<input type='hidden' name='id' id='id' value='999' /> 


How you add the value will depend on how you are calling the edit. If it is in a URL then ChronoForms will set it for you.

Bob
KarelMG 14 Sep, 2012
Hi Bob,

Thanks for your quick response

In the mean time I found on the forum the solution that works.

I have added a Hidden Box in the Show HTML with the following configuration:
Label Text: cf_id
Field Name: cf_id
Field Default Value: <?php echo $form->data['cf_user_id'] ?>

Regards,

Karel
BionicNelly 05 Apr, 2013
Karel, thank you for posting this - this worked for me also.

I've added your notes using Okular (useful for adding notes in Ubuntu system).

Cheers.

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

VPS & Email Hosting 20% discount

{item:title} {images:#}