Dropdown list imported from lists

I have this line of code:

<?php // echo generate_select_list('form_abook_type', 'abook_type', ($row['abook_type'] ?? null), '', 'Unassigned', 'form-control-sm', 'typeSelect(this.value)'); ?>

that leads to the image below where we imported the address book types from the list:

I want to do this as well but for the states ( I changed name of State to Kaza in the figure), but I think I am missing something or the list name is wrong, does anyone know what is the correct name fore the States list if I want to add it to my code

code I am trying to change that was inspired from the code above:

<?php echo generate_select_list('form_abook_state', 'abook_state', ($row['state'] ?? null), '', 'Unassigned', 'form-control-sm', 'typeSelect(this.value)'); ?>

Empty list of states

full code can be found in addrbook_edit.php

As far as I know the list_id should be state not abook-state.

1 Like

Thank you! The list is now populated :slight_smile:
I do have one more question, do you have any idea why the selected value isn’t being saved into the database? is there some other line of code that should be edited with the one mentioned above?

The form field name in the Address book is form_state. You need to make your generated select statement have the same form name in order for the data to save properly. I believe in your example its the form_abook_state in the first argument, but don’t know for sure, so you’d need to test it out.

1 Like

It worked!!! Thank you so much

I’ve been meaning to get around to having the address book state and country lookup use the standard openemr dropdowns. If you have this working, it would be great to contribute your code to OpenEMR via a pull request.

See our contributing readme here (Step 9 is the most relevant once you have your code on github) if you’ve never done a pull request before openemr/CONTRIBUTING.md at master · openemr/openemr · GitHub.