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.

Drop Down List / No duplicates

  1. How do I configure the drop down field type to not show selections for items that have already been chosen from the list (no duplicates stops the add of record, but it would be nice to not show the ones on file.
    I have reviewed and searched for 2 days on how i might do this in php with prerender, but all of the examples use simple calls to getposts.
    My guess is that the combination of not fully understanding the db structure form my gforms tables and how to organize the php to do what i need is the culprit.
    Any help would be great.
    Thanks in advance.

    Posted 11 years ago on Wednesday March 6, 2013 | Permalink
  2. http://rotaryribfest.muldowneyarts.net/purchase-a-booth-for-2013-event/

    functions.php:

    <?php
    // current url function
    function current_url()
    {
    	$pageURL = 'http';
    	if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
    	$pageURL .= "://";
    	if ($_SERVER["SERVER_PORT"] != "80") {
    		$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
    	} else {
    		$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
    	}
    	return $pageURL;
    }
    //cull out booths already reserved
    add_filter("gform_pre_render", "populate_dropdown");
    //add_filter("gform_admin_pre_render", "populate_dropdown");
    function populate_dropdown($form){
    global $wpdb;
        if($form["id"] != 2)
           return $form;
        $posts = $wpdb->get_results("SELECT boothname FROM $wpdb->booth");
        $items = array();
        $items[] = array("text" => "Select a slot", "value" => "");
        foreach($posts as $post)
            $items[] = array("text" => $post->boothname, "value" => $post->boothname);
        foreach($form["fields"] as &$field)
            if($field["id"] == 7){
                $field["choices"] = $items;
            }
        return $form;
    }
    Posted 11 years ago on Thursday March 7, 2013 | Permalink
  3. One of our developers has a solution over at Gravity Wiz for this called "GP Limit Choices". You can read about it here: http://gravitywiz.com/gravity-perks/

    I don't know of a way to do it with gform_pre_render.

    Posted 11 years ago on Tuesday March 12, 2013 | Permalink