Dynamically generate List Dropdown choices

The ‘gravitywp_list_dropdown_choices’ filter allows you to adapt or define the list dropdown choices.


add_filter( 'gravitywp_list_dropdown_choices', 'my_custom_fuction', 10,6 );


  • $drop_down_choices – Array of dropdown choices each with a ‘value’ and a ‘text’ (label) property.
  • $field – The Field Object.
  • $column – The column name (label).
  • $value – The fields value as serialized string.
  • $form_id – The form id.


This example populates the List Field Dropdown column ‘Select Product’ for field with ID 1 and form with ID 514 with 3 products.

 * Function: gravitywp_list_dropdown_choices.
 * @param array    $drop_down_choices Array of dropdown choices.
 * @param GF_Field $field             The Field Object.
 * @param string   $column            The column name (label).
 * @param string   $value             The fields value as serialized string.
 * @param int      $form_id           The form id.
 * @return array
function gravitywp_list_dropdown_choices( $drop_down_choices, $field, $column, $value, $form_id ) {
    if ( $form_id == 514 && $field->id == 1 && $column == 'Select Product' ) {
        $drop_down_choices = array(
                'value' => 'p1',
                'text'  => 'Product 1',
                'value' => 'p2',
                'text'  => 'Product 2',
                'value' => 'p3',
                'text'  => 'Product 3',
    return $drop_down_choices;
add_filter( 'gravitywp_list_dropdown_choices', 'gravitywp_list_dropdown_choices', 10,6 );


You can place this code in your themes functions.php.

List Dropdownv2.0.1

For this functionality to work you need to install the GravityWP - List Dropdown Add-on.

Read more

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.