PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Why gform_field_value works for a text field but not for a dropdown?

  1. brasofilo

    Both fields are allowed to be populated dynamically and have its parameter name.

    This works:

    add_filter( "gform_field_value_text_field", "populate_text_field" );
    function populate_text_field( $value )
       return "Dynamic populated";

    But this doesn't:

    add_filter( "gform_field_value_dropdown_field", "populate_dropdown_field" );
    function populate_dropdown_field( $value )
    	$value = array(
    		array( 'text'=>'Foo 1', 'value'=>'foo1', 'isSelected'=>false, 'price'=>'' ),
    		array( 'text'=>'Foo 2', 'value'=>'foo2', 'isSelected'=>false, 'price'=>'' ),
    		array( 'text'=>'Foo 3', 'value'=>'foo3', 'isSelected'=>true , 'price'=>'' )
       return $value;

    I know I can use gform_pre_render, and that's how I'm solving this.
    But _field_value is much more easy.

    I really did a research here in the forum but couldn't find an answer..
    Am I missing something?

    Posted 11 years ago on Saturday December 8, 2012 | Permalink
  2. I confirmed with the developers: you can use gform_field_value_$parameter_name to pre-select an existing choice, but to populate a drop down, you need to use gform_pre_render, as you have done here.

    Posted 11 years ago on Friday January 4, 2013 | Permalink