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?
If I understand you well you need a User Attribute. It will be saved automatically in the
UserInfoand if you set the options correctly it will be displayed on the user account page / add user page.Note that all the following code should go in a Controller file in
/application/controllersor even better inside a package. How to create a package is well documented here. That way your site can be updated without any problems.Your associative array with dynamic values from a DB table or other sources to be filled in the User Attribute (a Dropdown in this case):
Attributes parameters:
Classes used:
Define the Attribute Type:
Check if the Attribute already exists and if not, create it:
And finally fill the options into the select: