Save user info from dropdown user list

langus 15 Sep, 2012
Hi, I have a form that fills the admin. In this form is a dropdown list of all users.
I got this with code:

echo JHTML::_('list.users', 'user_id', true, 0, NULL, 'name', false);


I want that information to be included in the form and saved in the db to the selected user and then in another form, read by him.
All infos are saved in DB but I can not pass user_id to cf_user_id.
How can I save it and later retrieve it for specific user?
Please help
langus 15 Sep, 2012
Ok. I added Custom Code in Events to On Submit before DB Save:


<?php
$form->data['cf_user_id'] = $form->data['user_id'];
?>

And now my cf_user_id is saving the user id under the cf_user_id.
But I still do not know how to get the data from specific user...
GreyHead 15 Sep, 2012
Hi Langus,

You could just change the name in the list.users code I think
echo JHTML::_('list.users', 'cf_user_id', true, 0, NULL, 'name', false);

Please see this FAQ

Bob
langus 15 Sep, 2012
I do not know why but the solution from the FAQ does not work for me.
In the user menu I have the link and it point to form with DB Multi Record Loader.
There is:
1. Custom code
<?php
$user =& JFactory::getUser();
$form->data['user_id'] = $user->id;
?>

2. DB Multi Record Loader with Request Param 'user_id'
3. Custom code:
<table border="1" cellspacing="5" cellpadding="5">
  <tr>    
    <th scope="col">Numer badania</th>
       
    <th scope="col">Data badania</th>
       
    <th scope="col">Data otrzymania badania</th>
       
    <th scope="col">BMI</th>
       
    <th scope="col">Waga</th>
       
    <th scope="col">Wzrost</th>
       
    <th scope="col">Obwód pasa</th>
       
    <th scope="col">Obwód bioder</th>
      </tr>
  <?PHP
foreach ($form->data['wpr_badania'] as $detail):
?>
  <tr>
    <td><?php echo $detail['nrb']; ?></td>
    <td><?php echo $detail['data_badania']; ?></td>
    <td><?php echo $detail['data_o_badania']; ?></td>
    <td><?php echo $detail['bmi']; ?></td>
    <td><?php echo $detail['wzrost']; ?></td>
    <td><?php echo $detail['waga']; ?></td>
    <td><?php echo $detail['obwod_talii']; ?></td>
    <td><?php echo $detail['obwod_bioder']; ?></td>
  </tr>
  <?php endforeach; ?>
</table>


Not working...

When the user is logged in he should see only the records for logged user but he can see all records for all users.
langus 16 Sep, 2012
How to pull out the data only for user who is logged in.
langus 16 Sep, 2012
I finally got this working.

I put cf_user_id in DB Field and user_id in Request Param field.

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