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 with automatically populating dropdown

  1. Trisha
    Member

    I found the instructions here in the forum on how to Automatically populate a dropdown with post titles and it works like a charm, does what I need....

    Except that it doesn't support validation if I make that text field (that gets replaced with the dropdown) a required field - the problem is in this line:

    11	    //Adding initial blank value.
    12	    $items[] = array("text" => "", "value" => "");

    While I have entered the default text I want ("Please select your product"), and left the "value" => "" blank so that there should be no value (which should trigger an error on validation), the plugin still puts in the text as the value, negating the validation.

    What can I do to make sure that the value stays blank and that the field is validated?

    Posted 13 years ago on Friday September 9, 2011 | Permalink
  2. Hi Trisha,

    You will need to update the form property enableValues to true:

    [php]
    $form['enableValues'] = true;
    Posted 13 years ago on Friday September 9, 2011 | Permalink
  3. Trisha
    Member

    Thank you David..... I added your suggestion, but the value is still being populated with the text, instead of being blank, as would be needed to trigger the validation. I deliberately did not put in a default value, only default text.

    So the question is, how can I modify the aforementioned code to have it *not* take the text and use it for the value?

    Posted 13 years ago on Saturday September 10, 2011 | Permalink
  4. Hi Trisha,

    Would you mind sending me a WP and FTP login to your site. I've tested on my end and it is working with out issue.

    Posted 13 years ago on Tuesday September 13, 2011 | Permalink
  5. Anonymous
    Unregistered

    You will need to update the form property enableValues to true:

    I'm having the same problem, using Gravity Forms v1.6.8.1 with WordPress 3.4.2 -- has anyone found a solution?

    Posted 12 years ago on Monday October 22, 2012 | Permalink
  6. Anonymous
    Unregistered

    This problem looks to be a bug when the form is set to use Ajax for submissions.

    With Ajax submissions disabled, the dynamically populated drop-down fields do not get wiped out during the form validate routine.

    Posted 12 years ago on Thursday October 25, 2012 | Permalink
  7. Do you have a link to the page where we can see your form in action? Maybe embed it in two different pages, once with AJAX, once without, so we can see the difference.

    Posted 12 years ago on Thursday October 25, 2012 | Permalink