Forums

Dropdown: select 1, write many

brononius 31 Jul, 2013
I'm creating a table that should contain some data of my joomla users.

So I'm using a dropdown list of all my users through a DB multi loader. And I can nicely write fe the name into the new table. So far, so good.

But I would like now that once I select the name in the dropdown, the id/name/mail is written into the new table (seperate colomns).


Any tips what direction I should look?
GreyHead 31 Jul, 2013
Hi brononius,

Please see this FAQ about getting user info. If you get the user ID (or username)from the drop-down then you can look up the remaining information in the On Submit action before the DB Save action.

Bob

Note: I recommend that you *don't* so this unless there is a very good reason. Just save the User ID and look up the other information later when you need it; that way you will always get the latest version.
brononius 31 Jul, 2013
I know, but it's an existing joomla component that I want to make a bit easier for my users. And that component reuse(copy) the id/name/mail. :$

What I've done now:
- OnLoad
Create 'DB Multi Record Loader'

- Preview
A dropd-down list with fieldname=userid and dynamic data > value=id, text=name


- OnSubmit
A custom code:
     <?php
     $user =& JFactory::getUser($userid);
     $form->data['email_address'] = $user->email;
     $form->data['client_name'] = $user->name;
     $form->data['user_id'] = $user->id;
     ?>

But he's always using the logged in user.
And not the userid of the drop-down list.
The getUser($userid) is not been filled in by the fieldname=userid? :$
GreyHead 31 Jul, 2013
Hi brononius,

This line
$user =& JFactory::getUser($userid);
should probably be:
$user =& JFactory::getUser($form->data['userid']);

Bob
brononius 31 Jul, 2013
Works perfectly!!!


Sometimes it's so clear (once you see it) that you could ...
Thanks!
This topic is locked and no more replies can be posted.