Problems with saving form values in CB (again)

fribse 06 Sep, 2013
For some reason, all of the sudden I dont's see my new users form data being saved to their profile.
It's regarding the form discussed previously here: http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=2&t=87454&start=15

As the form can both be used by the currently logged in user, and for a third party, I'm checking if the mail address entered in the form is the same as the one on the currently logged in user.

This is done by a custom server side validation:
<?php
   $user =& JFactory::GetUser();
   if ($user->email <> $form->data['email1']) {
      return false;
   };
?>


But it seems that this code does not work any more???

Another question: Is there a way I can prepopulate the fields in the form shown with the currently logged in users data?
fribse 07 Sep, 2013
Ok, regarding the prepopulate, I found the tutorials on the db load action, but I can't figure out how to do it.
I have a couple of fields I want to extract from the currently logged in user.
full name
e-mail
So I guess I should use the db_record_loader (and not multi-record, as that seems to work with multiple seperate records).
But my understanding of english doesn't really match the tutorial, sorry 😶
Which parameter should I put the currently logged in user id, and what do I write to get the user_id, and where do I put in the navn1 and telefon1 (which are the form field names).
GreyHead 07 Sep, 2013
Hi fribse,

I have the usual statement that I don't use CB and know very little about it :-(

This code still works (at least up to Joomla! 3.1)
<?php
$user =& JFactory::getUser();
$form->data['user_id'] =& $user->id; 
?>

If you want to retrieve a single record then you do need the DB Record Loader, not the DB Multi Record Loader. That will work with any single table. (My recollection is that some CB data is saved in multiple tables in which case you might need to use the CB code to retrieve it. See the other thread you liked to for example.)

Bob
fribse 08 Sep, 2013

This code still works (at least up to Joomla! 3.1)

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


Ok, now I'm a bit confused, this get's a users data, and puts it in the form, right?
So I that better than using the DB record loader when it's data on the current user, or?

The code I showed above, should compare the email address of the currently logged in user, with the email address of the form, but if I read your example correctly, then my code should work.

If you want to retrieve a single record then you do need the DB Record Loader, not the DB Multi Record Loader. That will work with any single table. (My recollection is that some CB data is saved in multiple tables in which case you might need to use the CB code to retrieve it. See the other thread you liked to for example.)


I don't need to fetch CB data, it's standard Joomla user data. It's the users email address and full name (CB doesn't store the standard Joomla user data, as that would be a waste of DB space :-) ).
I tried building the DB record loader like this:
[attachment=1]basic.png[/attachment]
[attachment=0]advanced.png[/attachment]
But that didn't give me anything? What I would like to accomplish is to get the currently logged in users full name (name field in kef_users) and I guess a second DB loader should get the email address of the currently loggedin user?
fribse 08 Sep, 2013
Ok, I entered the custom code:
<?php
$user =& JFactory::getUser();
$form->data['navn1'] =& $user->name;
$form->data['email1'] =& $user->email;
?>

And that gave me the prepopulation, so I guess that was a lot easier than using the DB loader...
GreyHead 08 Sep, 2013
Hi Fribse,

That's excellent. Using the Joomla! User object (which is what $user is there) is much easier and preferred to using the DB Record loader as Joomla! has already got this data for you and holds it in memory or in the User session.

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