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.

Get selected checkbox group values

  1. Ketiga
    Member

    Hello,

    Is there any way to capture the post (selected) values of a checkbox group in an array?
    Tried the $entry object but no luck yet...

    I can get the value of a single box, but I need multiple in a group.
    I need those values to match some other values in my database.

    Also when I have those values, what's the best way to output/print them to my screen so I can debug and see if things work the way they should?

    Please advice.

    Posted 11 years ago on Friday September 7, 2012 | Permalink
  2. For debug, you can use the gform_pre_submission or gform_after_submission hooks, then dump the $entry, $form or $_POST using print_r, like this:

    [php]
    print_r($form);
    print_r($entry);
    print_r($_POST);

    Depending on how things are processed in your installation, you might be better off logging those dumped variables, rather than just printing them to the screen. For quick and dirty, printing to the screen might be fine.

    Hook documentation:
    http://www.gravityhelp.com/documentation/page/Gform_after_submission
    http://www.gravityhelp.com/documentation/page/Gform_pre_submission

    Posted 11 years ago on Friday September 7, 2012 | Permalink
  3. Ketiga
    Member

    Hi Chris,

    Thanks for your reply.

    My question is specifically about a checkbox group.

    Is there a way to get the selected values in a checkbox group?
    I need to further process those values. One way would be to store them inside an array so I can use php to handle it from there.

    If there's a better way please let me know.

    Normally I would use the same name for each of the checkboxes to put the selection into an array, but I have not found a way to manipulate the names of inputs in Gravity Forms. Calling each of the boxes individually is not an option.

    Posted 11 years ago on Friday September 7, 2012 | Permalink
  4. Sorry, I figured for debugging that was all you needed. Let me reread your request and see if I can help.

    Posted 11 years ago on Friday September 7, 2012 | Permalink
  5. Ketiga
    Member

    No worries, thanks for looking at it.

    Posted 11 years ago on Saturday September 8, 2012 | Permalink
  6. Getting back to this one. You said:

    Tried the $entry object but no luck yet...

    All the values are in the entry. If in your form field 7 is a group of check boxes, and someone checks box 1 and box 4, you will have these values in the $entry object:

    [php]
    $entry['7.1'];
    $entry['7.4'];

    Be sure to quote the field number there. $entry['7.2'], $entry['7.3'] and $entry['7.5'] will also be present but will have no value.

    Does that accomplish what you need to do?

    Posted 11 years ago on Saturday September 15, 2012 | Permalink
  7. have the same question, but i need to know which of them has values/selected.. does it mean i need to do something like the code below:

    $entry['7.1'];
    $entry['7.2'];
    $entry['7.3];
    $entry['7.4'];
    ...
    $entry['7.10'];

    wherein the one who fills up the form checks only option1 and option10

    Posted 11 years ago on Tuesday October 23, 2012 | Permalink