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.

Dynamically Populated Drop Down Value and Text

  1. I have a drop down field on a form that is being dynamically populated using the pre_render code as described in the documentation. When I send a notification email, I want the "text" of the chosen option to be included, not the "value" of the selected option. I have tried to use {fieldname:id} and other options, but it always seems to return the "value" not the text.

    Interestingly, when I manually added the options to the drop down, the text/value issue worked as expected.

    Can you enlighten me?

    Steve

    Posted 5 years ago on Wednesday December 12, 2012 | Permalink
  2. David Peralty
    Administrator

    Can you post your code on a site like pastebin so we can take a look at it? Also, can you link to your form? I want to confirm that values are being written and assigned correctly. {fieldname} should give the label and {fieldname:value} should give the value.

    Posted 5 years ago on Wednesday December 12, 2012 | Permalink
  3. Thank you. Here is the code for populating the dropdown.

    // used for populating tour webinars
    	add_filter('gform_pre_render_16', 'populate_tour_webinars');
    	function populate_tour_webinars($form){
    	    global $post;
    
                // Get posts for "GiftWorks Overview Tours"
    	    $args = array( 'post_type' => 'event',
    				'orderby' => 'menu_order',
    				'tax_query' => array(
    				     array(
    					'taxonomy' => 'event-category',
    					'field' => 'slug',
    					'terms' => 'tours'
    				     )
    				),
    				'numberposts' => 10);
    	    $posts = get_posts( $args ); 
    
    	    // Create drop down tour items array.
    	    $items = array();
    
                // Add initial blank value.
    	    $items[] = array("text" => "Select Date/Time (Eastern Time)", "value" => "Select Date/Time (Eastern Time)");
    
    	    // Add post items to the tour items array
    	    foreach($posts as $post)
    		{
    		$gtwid = get_post_meta($post->ID, 'gtwid', true);
    		$startdate = get_post_meta($post->ID, '_eventorganiser_schedule_start_start', true);
    		$enddate = get_post_meta($post->ID, '_eventorganiser_schedule_start_finish', true);
    		$startdatetime = strtotime( $startdate );
    		$enddatetime = strtotime( $enddate );
    		$display = date("D, M j, Y g:i A", $startdatetime ) . ' - ' . date("g:i A", $enddatetime ) . ' EST ' .
                             date("(m/d/y)", $startdatetime );
    		$items[] = array("value" => $gtwid, "text" => $display);
    		} 
    
    	    foreach($form["fields"] as &$field)
    	        if($field["inputName"] == "gtwid"){
    	            $field["choices"] = $items;
    	        }
    	    return $form;
    	}
    Posted 5 years ago on Wednesday December 12, 2012 | Permalink
  4. Here is a link to the current form:
    http://www.giftworksconnect.com/get-a-guided-tour-test/

    Posted 5 years ago on Wednesday December 12, 2012 | Permalink
  5. Any thoughts?

    Posted 5 years ago on Wednesday December 12, 2012 | Permalink
  6. Steve, I am going to close your other topic as a duplicate of this one:
    http://www.gravityhelp.com/forums/topic/drop-down-display-value-for-dynamic-population

    Posted 5 years ago on Thursday December 13, 2012 | Permalink
  7. No problem...just wasn't sure if it got lost in the shuffle. What is going on with the drop down?

    Posted 5 years ago on Thursday December 13, 2012 | Permalink
  8. It has not been lost in the shuffle. With the release of WordPress 3.5 yesterday our support volume increased. We still strive to respond to all requests within 48hrs, as described here:
    http://www.gravityhelp.com/support-times/

    Posted 5 years ago on Thursday December 13, 2012 | Permalink
  9. I am sorry to be a pest. We are kind of in a bind since this is affecting our production server. Is there any way you could provide me with a quick update. Is this a bug, a known issue, did I do something wrong in my code, etc?

    Any help would be appreciated.

    Steve

    Posted 5 years ago on Saturday December 15, 2012 | Permalink
  10. Steve, I took a look at this form: http://www.giftworksconnect.com/get-a-guided-tour-test/

    In the source I see this for your test form: http://pastebin.com/ZzV5VDZ1

    From that, if field 12 were named "dropdown1" and field 13 were named "dropdown2", you should be able to get the label for field 12 like this:

    {dropdown1}

    and the value like this:

    {dropdown1:value}

    The label is the default, and you have to specify :value to get the value. Is that part not working in your notifications?

    Posted 5 years ago on Monday December 17, 2012 | Permalink
  11. Hi Chris,
    If you submit this form (http://www.giftworksconnect.com/get-a-guided-tour-test/) you will see that the manually entered drop down works fine...like you described above. But, the one labeled "Drop Down - Dynamically Populated" does not work properly. If you submit the form, you will see the result page that simple echos back the values. You will see the results:

    *** Dynamically Populated ***
    Result: 290423257

    *** Manually Populated ***
    Result : First Choice

    The manually populated one returns the proper label (text value of the dropdown) but the dynamically populated one returns the value of the dropdown.

    Please submit the form to see how it's behaving and let me know what might be happening.

    Steve

    Posted 5 years ago on Tuesday December 18, 2012 | Permalink
  12. Chris,
    I really hate to be a bother - this seems like a simple thing I must be overlooking. We've checked the code to dynamically populate the drop down...maybe we're missing something simple.

    Steve

    Posted 5 years ago on Tuesday December 18, 2012 | Permalink
  13. Chris,
    I have been patiently waiting for a response. I paid money for Gravity Forms on the basis that I would receive some type of support. I see that you and other support people are providing answers and responses to other questions. If you could please simply let me know that this is a known bug, a problem with my coding, etc. I have provided all the information you should need to diagnose this issue. If there is something else I can provide, please let me know. We are using Gravity Forms in production and this is a problem. I have hired developers to make changes to our website and am paying them to wait for your response. Please let me know the status of this issue.

    Steve

    Posted 5 years ago on Wednesday December 19, 2012 | Permalink
  14. Steve, I sent you an email. Please respond to that so we can work through this together. Thank you.

    Posted 5 years ago on Wednesday December 19, 2012 | Permalink
  15. I have a similar issue that i'm trying to solve. My dropdown that is populated using a taxonomy will only save the field value and not the data i want it to save i.e. 1234 and not a location.

    Was this resolved?

    Posted 5 years ago on Tuesday March 19, 2013 | Permalink
  16. digitaldev
    Member

    I am having the same problem as well. The option name should be passing to the Email/Entry and the value should be passing to the database.

    Instead the value is being passed to both the Email/Entry and also the database.

    Posted 5 years ago on Wednesday March 20, 2013 | Permalink