Autofill address after selecting user from dropdown

mrnorx

New Member
Hi,
Im currently trying to create a simple invoicing application for my small business. I have enabled the user_profiles plugin in Joomla so each user has their address stored in the joomla database.

Ive created a list called invoices and in that list I have a database join called invoices___client_name, this is a drop down which selects a user from the registered joomla users and stores their ID, in this example Im using John Smith who has a Joomla ID 81. Ive then created a field called invoices___address_1 which I would like to autofill with the address1 data stored by Joomla when I select the client name from the dropdown.

Ive installed the autofill plugin and watched the tutorial but after several days Im getting nowhere. Im not too good with SQL but keen to learn. Can anybody advise me on the best way to do this task and I can then adapt it for the rest of my form.

Ive attached a picture of the structure of the user profile table in Joomla if it helps.

Thanks in advance for any assistance.
 

Attachments

  • user-table.jpg
    user-table.jpg
    73.4 KB · Views: 36
Unfortunately that's not going to work.

The autofill plugin assumes that you are getting your data from a table with a single row matching your "FK" (foreign key). So in your case, it would expect a table of the form ...

user_id, address1, address2, city, state, zip, (etc)

... with a single row for each user (id), and a specific column for each value you want to map. So your FK selects that row, then you can "map" each of those field names from a single row to elements on your form, like ...

{"profile___address1":"yourtable___address1","profile___address2":"yourtable___address2"}

But the format of that profiles table isn't like that, it has multiple rows for each user_id, with a single profile field on each row, and the profile field name is in the data, it isn't the column name So there's no way to lookup all your fields from a single FK.

The best way to approach this would be to use Fabrik to maintain your profile data, using your own profile list, and the 'juser' form plugin.

-- hugh
 
Hugh, Many thanks for the reply.

Im glad I wasn't missing something simple. I will create a client list in Fabrik with all the details as you suggest and take a look at the juser plugin. I think with that I have all I need to complete this part of my invoicing application. :)

Thanks again

David
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top