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.

Retrieving all values from checkbox in gform_validation

  1. wollemi
    Member

    I have multiple checkboxes attached to one field. How do I retrieve all values for it? I know I retrieve the value for it like this:

    $field_value = rgpost("input_{$field['id']}");

    I want to ensure that only 5 out of X checkboxes have been selected to pass the validation. Where do I go from there? Thanks.

    Posted 12 years ago on Thursday January 19, 2012 | Permalink
  2. wollemi
    Member

    I found my solution. Might not be the most elegant and would love to hear any opinions. I basically checked each checkbox to see if it was set via $_POST['assigned-id'] in a loop.

    Posted 12 years ago on Thursday January 19, 2012 | Permalink
  3. That's not a bad way of doing it. Would you like to share your code here to help anyone else who is trying to do the same thing?

    Posted 12 years ago on Friday January 20, 2012 | Permalink
  4. This seems like exactly what I am trying to accomplish . Is there any way of anybody adding a little more detail to the above solution. What I am trying to accomplish is I have a form which post to a custom post type "listings". Using checkboxes populated by taxonomies I want to be able to populate all boxes checked .

    So for instance. In the listings post type I have a taxonomy called Business Types. i.e. Band, DJ, Hotel and so on. If someone chooses Band and Dj and then submits I would think that in the backend you would see both options selected. This doesn't seem to be working for me. After hours of trying to accomplish this I am at wits end.

    Thanks for any help ahead of time

    Posted 12 years ago on Thursday February 16, 2012 | Permalink