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.

Pre-Select Checkbox Option (shortcode)

  1. HI, I am trying to figure out if it is anyhow possible to preselect a field in checkbox for forms. For example on this site: http://extrafreshcontent.com/ - I have a leadgen form with 4 options. I want to use the same form on other pages... except like on blog management page I'd really want to have the option pre-selected?

    Posted 11 years ago on Friday November 23, 2012 | Permalink
  2. David Peralty

    You couldn't do this within the shortcode. You would have to use custom PHP and our gform_pre_render hook to make this happen.

    http://www.gravityhelp.com/documentation/page/Gform_pre_render

    Posted 11 years ago on Friday November 23, 2012 | Permalink
  3. Igneus
    Member

    If you don't wish to write php code you can just duplicate the form and it will look exactly the same and attach it to each page using the short code (it's not a long one) and the options will be pre-selected based on each form. It's kind of sloppy having tons of forms, but I do it and it doesn't really hurt the speed of my site since I use compression.

    Honestly that's the safest-non coding bet otherwise like David mentioned you will have use a pre-render hook which I honestly have no luck with - I've done my best to use that for my forms, but when you have over a 100 fields that's a lot of assigning for each option.

    Posted 11 years ago on Friday November 23, 2012 | Permalink
  4. I talked to the development team about this once, and you can use one form and pre-select checkboxes by sending field values in the shortcode. Here is the shortcode I used on a page:

    [gravityform id="215" name="Pre-select a checkbox" title="false" field_values="sport=baseball,tennis"]

    Here's the page: http://gravity.chrishajer.com/pre-select-a-checkbox-in-the-shortcode/

    I did not select a default checkbox when I set up the field.

    You'll see that Baseball and Tennis are pre-checked. I used values for my checkboxes and sent those (you see they are lower case in the shortcode, and I used lowercase when I entered the form values. Also, be sure on the Advanced tab, you check "Allow field to be populated dynamically" and then enter a parameter name. I used "sport" as my parameter name. You can see that in use if you use the query string to set a value. It will override the shortcode values:

    http://gravity.chrishajer.com/pre-select-a-checkbox-in-the-shortcode/?sport=football

    Hope that helps.

    Posted 11 years ago on Monday November 26, 2012 | Permalink