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.

dynamic population issue

  1. i'm missing something simple.
    i have a simple 3 field form and i want to populate a text box or a drop down. i just tried to paste the code from the simple example. found in the docs, but it does not work.
    i'm using genisis theme and i've pasted it into the functions.php in the theme subfolder.
    nothing is loading.
    what would cause this?

    thanks
    Kim

    Posted 12 years ago on Wednesday July 18, 2012 | Permalink
  2. Kim, we're going to need some more information from you in order to help you better.

    1. Which do you prefer to populate, a text area or a drop down? And with what are you trying to populate it?
    2. Please post a link to your form and point out what is not working
    3. Please let us know which "simple example" you are referring to
    4. Please post your complete functions.php at pastie.org or pastebin.com so we can check for syntax error and verify your implementation
    5. Please define "nothing is loading". Is you page blank? Is the page there but the form is not? Is the function not working so your values are pre-populated?

    The more information you can share, the better, so we can help you resolve this issue.

    Posted 12 years ago on Wednesday July 18, 2012 | Permalink
  3. the example can be found here: http://www.gravityhelp.com/documentation/page/Allow_field_to_be_populated_dynamically
    my page is here: http://50.87.21.168/samplepage/
    "nothing shows up": the fields are not populated with the data in the action_result.
    i tried it on both the second drop down and when i could not get that to work (the ddl did not contain the value) i attempted populating a text box.
    the template i pasted the function into is "themepath" functions.php.

    please let me know if you need more info.
    kim

    Posted 12 years ago on Wednesday July 18, 2012 | Permalink
  4. i see the issue now i was using the full name with the prefix for the field name

    Posted 12 years ago on Wednesday July 18, 2012 | Permalink
  5. Is this issue resolved in that case?

    Posted 12 years ago on Wednesday July 18, 2012 | Permalink
  6. I have a similar issue with the code example. I am trying to populate an option field with a label and price but I only get the first letter and both text and value produce an item in the drop down list.

    http://pastie.org/4280708

    I'm working locally, here's a screen shot: https://dl.dropbox.com/u/159555/Screen%20Shot%202012-07-18%20at%204.34.58%20PM.png

    Posted 12 years ago on Wednesday July 18, 2012 | Permalink
  7. David Peralty

    Just out of curiosity, can you add back in the following lines to see what happens:

    //Creating drop down item array.
        $items = array();
        //Adding initial blank value.
        $items[] = array("text" => "", "value" => "");

    Also, can you post your exact function?

    Posted 12 years ago on Thursday July 19, 2012 | Permalink
  8. If I add the Initial blank value I get a blank entry at the end of the list: https://dl.dropbox.com/u/159555/Screen%20Shot%202012-07-18%20at%209.30.20%20PM.png

    Here's the whole function: http://pastie.org/4281889 I've commented out some stuff I wasn't using.

    Posted 12 years ago on Thursday July 19, 2012 | Permalink
  9. I may have it working with

    //Adds a filter to form id 14. Replace 14 with your actual form id
        add_filter("gform_pre_render_1", populate_dropdown);
        function populate_dropdown($form){
    
            global $sp_photo_only;
            global $sp_photo_only_desc;
            global $sp_mounted;
            global $sp_mounted_desc;
            global $sp_folding;
            global $sp_folding_inside;
    
            $choices = array(array('text' => $sp_photo_only_desc,
                                   'value' => $sp_photo_only_desc,
                                   'price' => $sp_photo_only
                                  ),
                             array('text' => $sp_mounted_desc,
                                   'value' => $sp_mounted_desc,
                                   'price' => $sp_mounted
                                  )
    
                            );
    
            //Adding items to field id 8. Replace 8 with your actual field id. You can get the field id by looking at the input name in the markup.
            foreach($form["fields"] as &$field)
                if($field["id"] == 35){
                    $field["type"] = "select";
                    $field["choices"] = $choices;
                }
    
            return $form;
        }

    Will update after testing.

    Posted 12 years ago on Thursday July 19, 2012 | Permalink
  10. David Peralty

    Any update on this? I don't see why you would need to nest your array to get it to work though. Also, I don't know if you can give your dropdown a third property (price) like you've done.

    Posted 12 years ago on Thursday July 19, 2012 | Permalink
  11. Under "Creating and Array of Options" from the post at http://www.gravityhelp.com/documentation/page/Dynamically_Populating_Drop_Down_Fields it says you can use the Choices property to get these options.

    My data seems to get populated properly but I'm using this function in an option field and the cost of these dynamically populated options is not getting added to the base price of my product.

    Is there a special syntax I have to use to get the price field to populate with +$1.00 as opposed to $1.00 (without the plus)?

    Posted 12 years ago on Thursday July 19, 2012 | Permalink
  12. It seems the function converts an "Option" field to a "Drop Down". So how can I use the "Price" choice to add to the base price of my product?

    https://dl.dropbox.com/u/159555/Screen%20Shot%202012-07-20%20at%206.00.57%20AM.png

    Posted 12 years ago on Friday July 20, 2012 | Permalink
  13. thank both i'll be revisiting the issue now and i'll let you know.

    Posted 12 years ago on Friday July 27, 2012 | Permalink
  14. eman100
    Member

    Bump... this is almost exactly what I need... any progress on this?

    Posted 11 years ago on Thursday April 25, 2013 | Permalink
  15. Nothing yet.

    Posted 11 years ago on Monday April 29, 2013 | Permalink