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.

Problem Using Values from Dynamically Populated Drop Down Fields

  1. theslink2000
    Member

    I'm trying to pass the value of a drop down field that has been dynamically populated via the CSS method outlined on this forum and it works fine and can be seen here:

    http://pastie.org/4674484

    When the form is submitted I want to take the value in the field and copy it to a hidden field which creates the post title via the Custom Post Types Addon. This works fine with every other field but not these, I've tried turning the advanced interface off but it makes no difference. I've tried various methods and nothing seems to work, here are the two methods I know work with other fields:

    add_filter('gform_pre_render_3', 'fill_med_fields');
    function fill_med_fields($form) {
        ?>
    
        <script type="text/javascript">
        jQuery(document).ready(function($){
    
            // update "#input_74_9" to the HTML ID of your field from which the value will be retrieved
            $('#input_3_9').blur(function(){
                // update the "#input_74_11" to the HTML ID of the field that should be updated
                $('#input_3_1').val($(this).val());
            });	// update "#input_74_9" to the HTML ID of your field from which the value will be retrieved
        });
        </script>
    
        <?php
        return $form;
    }
    add_action('gform_pre_submission_3', 'populate_med_title');
    
    function populate_med_name(){
    	$_POST["input_3"] =  $_POST["input_1"];  //Set the contents of field 18 to the same as field 6
    }

    The only other method I can think of is to manually edit the post data after it's been stored and this seems a bit overkill considering it should work fine. Normally drop down fields aren't a problem so I think it is purely due to this method of dynamically populating

    Also it seems this method of populating causes issues with the Required option as even when you've selected an option it will throw an error.

    Posted 10 years ago on Thursday September 6, 2012 | Permalink
  2. You should not have to edit the post data after submission. What you want to do is possible. Can you post a link to this form and the post it creates?

    Why do you have to copy the value from the drop down to the hidden field? Can't you create the post title from the value of the drop down, without the interim step?

    Posted 10 years ago on Friday September 7, 2012 | Permalink
  3. theslink2000
    Member

    Sadly this is all running on local at the moment so I can't post a link.

    I'm only copying it across to a hidden field because I am using the Custom Post Types plugin and it only supplies a text field to be used as the post title so I am using a drop down (actually the product field because it's the nearest thing to what I actually want) then that information will be passed to the post title field to register the post. If there's a way of bypassing this I'd love to hear your thoughts so I'll outline my ideal scenario:

    The title field would be a drop down box that narrows down the possibilities (I currently have about 2500 but it's going to grow to potentially approaching 10,000, and I'm aware this is a little slow but they're all stored as product posts for another purpose) so when you user enters two characters it shows the relevant options etc. When the other fields are completed (there is another drop down that is populated based on user data that also doesn't allow the required setting at the moment) it saves the product as the post title.

    So what I've done is use the product field to select as it only allows one selection, then pass that to the hidden title field to make it save correctly. Everything else is working I'm just getting blank post titles.

    Does that make any sense?

    Posted 10 years ago on Friday September 7, 2012 | Permalink
  4. theslink2000
    Member

    Chris?

    Posted 10 years ago on Tuesday September 11, 2012 | Permalink
  5. theslink2000
    Member

    Ok, scratch most of that. It does populate in the pre_submission hook, it was a typo.

    However, if I populate it via the CSS method or using the drop down fields populate from post type option I cannot seem to predetermine an selection like I can if the list is preset.

    Does anyone know a work around for this? It's pretty important.

    Thanks.

    Posted 10 years ago on Tuesday September 11, 2012 | Permalink
  6. theslink2000
    Member

    Thinking about it this is really a separate issue, I'll post it in another topic.

    It can be found here: http://www.gravityhelp.com/forums/topic/pre-select-drop-down-option-from-dynamically-populated-drop-down-field

    Posted 10 years ago on Tuesday September 11, 2012 | Permalink

This topic has been resolved and has been closed to new replies.