Dynamic select list on user account / add user page

Permalink
I want to add a form select input on the user account page / add user page with a dynamic list of options / values.

I know how to get the dynamic list form a database table and create a dynamic list for the select options.
echo $form->select('clientsID', $indexed_array, '0');


Question: Where and how to add this to the account/add user page and save this to the user table? (and the attribute tables)

c5dragon
 
ob7dev replied on at Permalink Reply
ob7dev
From my understanding you cannot override core administrator pages. But you can add your own single_pages to any of the admin areas. Of course you can go in and change the core code directly, it's just outside standard practices. I believe the file is located at /concrete/single_pages/dashboard/users/search.php and the controllers for changing what gets saved would be in the /concrete/controllers/single_page/dashboard/users/ directory.

But take this approach cautiously, I have personally never tried something like that, just a thought at how you could do it, but certainly not the most thorough way.
c5dragon replied on at Permalink Reply
c5dragon
The frontend part I got (something similar as the select from language or timezone).
But saving is a problem (and using the concrete's own functions).
mnakalay replied on at Permalink Reply
mnakalay
I think you can do that simply by creating a new user attribute. IF it is required on registration, it will appear on the add new user screen and you can choose a value from it that will be attached to the user being created
c5dragon replied on at Permalink Reply
c5dragon
I don't want to fill in all the client names (via concrete interface). The complete list with names and id's are in a second database synced with the clients software.

The problem with this user attribute is:
- You can't edit the values that way, only the display names.
- If something changes in the external db you also have to edit the display name in concrete.
- Have to exactly match names (strings with special chars), its better to match id's.

If i could fill in key -> value it wouldn't be such a problem.
mnakalay replied on at Permalink Reply
mnakalay
oh sorry, I missed the "dynamic" aspect of your question.
Then maybe you should create a new attribute type which would get the data from the db as you want it.

You could probably do it quickly enough by modifying the core select attribute type
c5dragon replied on at Permalink Reply
c5dragon
I planned to use this (manual input) as a backup. It works but is not ideal. (it breaks when the client name changes in the external db)

Better to modify the get_ and update_ functions from the controller.
But still not found the right combination of code to do it.