Title: dynamically populate select list
Last modified: December 2, 2020

---

# dynamically populate select list

 *  Resolved [georgedk4](https://wordpress.org/support/users/georgedk4/)
 * (@georgedk4)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/dynamically-populate-select-list/)
 * Hi,
 * I am trying to use the following filter to dynamically populate a select list(
   af/field/prefill_value) but it is not working. This is the code i have:-
 * [CODE]
    function prefill_form_field( $value, $field, $form, $args ) { $field[‘
   choices’] = array(‘key_1’ => ‘value 1’, ‘key_2’ => ‘value 2’); return $field;}
   add_filter( ‘af/field/prefill_value/key=field_5fc7aec97ca22’, ‘prefill_form_field’,
   10, 4 ); {/CODE]
 * Thanks

Viewing 1 replies (of 1 total)

 *  Plugin Author [fabianlindfors](https://wordpress.org/support/users/fabianlindfors/)
 * (@fabianlindfors)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/dynamically-populate-select-list/#post-13759729)
 * Hi!
 * The `prefill_value` filter can only be used to set the value for a field. For
   a select field, this would be which option is selected by default. To set the
   options dynamically you can follow this guide from ACF: [https://www.advancedcustomfields.com/resources/dynamically-populate-a-select-fields-choices/](https://www.advancedcustomfields.com/resources/dynamically-populate-a-select-fields-choices/).
 * All the best,
    Fabian

Viewing 1 replies (of 1 total)

The topic ‘dynamically populate select list’ is closed to new replies.

 * ![](https://ps.w.org/advanced-forms/assets/icon-256x256.png?rev=1894254)
 * [Advanced Forms for ACF](https://wordpress.org/plugins/advanced-forms/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/advanced-forms/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/advanced-forms/)
 * [Active Topics](https://wordpress.org/support/plugin/advanced-forms/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/advanced-forms/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/advanced-forms/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [fabianlindfors](https://wordpress.org/support/users/fabianlindfors/)
 * Last activity: [5 years, 6 months ago](https://wordpress.org/support/topic/dynamically-populate-select-list/#post-13759729)
 * Status: resolved