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.

Getting field choices as an array

  1. dochara
    Member

    Hi,

    I have a form which with a checkbox field. I have an existing gform_post_submission function for this form, which takes several single value fields and builds them into an array. That's no problem and is working fine.

    This is where I am stumped.
    - I have a multiselect field (checkboxes) which is populated by a query.
    - I need to get the selected values of this field into an array.
    - There is an unknown number of checkboxes, anything from 1 to dozens - if needs be I could get a count and stick it into a hidden field so at least I'd know that at the post submission stage.

    However I am not clear how (or if) I can get the selected choices of a multiselect field to build this array. I suppose I am looking for something vaguely like

    foreach($choices as $choice) {
    if($isselected) {
    // add value to array
    )
    }

    Is it possible to do this? Any pointers?

    Posted 8 years ago on Thursday March 22, 2012 | Permalink
  2. I'm also looking for such a solution.
    Have tried this http://www.gravityhelp.com/forums/topic/get-checked-checkboxes but it did not work for me

    Posted 8 years ago on Thursday April 5, 2012 | Permalink