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.

Dynamically Populate Checkboxes

  1. Is this (http://www.gravityhelp.com/forums/topic/dynamic-checkboxes) still the best method for populating checkboxes? Or should we be using the gform_field_value_parameter_name hook? If so what sort of value should be returned for checkboxes (assuming array of arrays?)?

    Posted 13 years ago on Tuesday December 13, 2011 | Permalink
  2. Hi Travis,

    The first approach would allow you to prepopulate the actual checkboxes available. The second approach would allow you to specify which checkboxes should be selected by default. When using the latter, you'll want to return a comma delimited list of options which should be selected.

    Posted 12 years ago on Wednesday February 1, 2012 | Permalink
  3. Hi,
    I'm a little confused. I'm trying to specify which checkboxes should be selected by default based on a true/false condition. It is not clear to me how to achieve this from the example code in the link above.

    Could someone provide a simple example showing how to check either box in a 2 option checkbox field.

    The filter:
    add_filter('gform_field_value_checkboxes', create_function("", "return 1;"));
    Seems to check all boxes in the field.

    Posted 12 years ago on Tuesday February 28, 2012 | Permalink
  4. Hi mmoriart,

    Assuming you have your field setup like so this, you can populate it using this code and it'll look like this when you load the form.

    Posted 12 years ago on Tuesday February 28, 2012 | Permalink
  5. Hi David,
    I tried your example but it doesn't seem to work. I configured my checkbox field like this and entered this code
    and neither box is checked. Whats going wrong? If I return 1, I get both checked.

    Posted 12 years ago on Wednesday February 29, 2012 | Permalink
  6. More field setup settings

    Posted 12 years ago on Wednesday February 29, 2012 | Permalink
  7. I still can't get this to work. Where is the code added? I have tried in functions.php and in the page template. Neither seems to work.

    Posted 12 years ago on Friday March 2, 2012 | Permalink