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.

Not all the selected values from checkboxes are being saved to the database

  1. Hi,

    So i have checkbox field in my form. I dynamically populate data into the checkbox. See following code:

    http://pastie.org/private/vq7jjiojoln0844iqyjq#26,28

    Basically, I am getting all custom type posts "Workshops" and populating the checkbox field with the value for each input being the post's title.

    But when i submit the form, not all the selected values are saved into the database.

    I referred to http://www.gravityhelp.com/documentation/page/Dynamically_Populating_Drop_Down_Fields and copy pasting the code from the article yeilds the same result.

    Posted 11 years ago on Thursday January 31, 2013 | Permalink
  2. OK, I just noticed that when i add the checkbox field into the form, it has by default 3 choices. When i dynamically populate the field, i have, lets say, 15 choices. But when i submit the form, only the first 3 are saved to the database. If i go to the form editor, edit the checkbox field and increase the number of choices to 15. Then it all works correctly.

    Now, I think this defeats the purpose of dynamic population. Because now I have to make sure, the number of choice is increased in the form whenever I add a new post.

    Posted 11 years ago on Thursday January 31, 2013 | Permalink
  3. I'll ask the development team for their input on this one.

    Posted 11 years ago on Friday February 1, 2013 | Permalink
  4. I heard back from one of the developers:

    The trick with dynamically populating checkboxes is that in addition to using the gform_pre_render hook, you also need to use the gform_pre_submission_filter. They can point to the same function, but both of them need to be used so that the function fires at the proper times. Following is an example that should help you out:

    http://pastie.org/6014156

    Posted 11 years ago on Friday February 1, 2013 | Permalink
  5. OK..thanks. I will verify if this works correctly and let you know.

    Posted 11 years ago on Monday February 4, 2013 | Permalink
  6. Please let us know.

    Posted 11 years ago on Tuesday February 5, 2013 | Permalink
  7. martyspellerberg
    Member

    Hi there,

    I'm experiencing the same behavior as Marc, where the number of dynamic choices saved being contingent on the number of empty choices added o the form via the admin. (Thanks for the tip Marc, BTW)

    I tried out the code posted here, but observed no change in the behavior.

    Posted 11 years ago on Tuesday February 5, 2013 | Permalink
  8. @marty, it would be best to open a new topic for your distinct issue, and share all the custom code you're using there. Use pastebin.com or pastie.org for lengthy code snippets.

    Posted 11 years ago on Tuesday February 5, 2013 | Permalink
  9. I think having more empty slots than you're going to use, using some code to overwrite those with the dynamic data, and pruning unused ones might work.

    I used a similar workaround that I explained in this thread:
    http://www.gravityhelp.com/forums/topic/dynamic-checkboxes-not-all-selections-being-saved

    Posted 11 years ago on Wednesday April 10, 2013 | Permalink