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.

Validate column of list field with gform_validation

  1. How do i get the input value of the every second column of a list field for use in gform_validation?

    I found this:
    http://www.gravityhelp.com/forums/topic/list-field-help#post-39885

    But '$list_values = unserialize($field[6]);' gives an empty array.

    Posted 7 years ago on Tuesday October 9, 2012 | Permalink
  2. Is the list field in your form field 6? If not, you will need to change that number to the actual field number.

    Can you dump the $entry using print_r and post the results at pastie.org or pastebin.com so we can see what field it actually is and what it contains? Thank you.

    Posted 7 years ago on Wednesday October 10, 2012 | Permalink
  3. I normaly get the input of the other fields by:

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

    But this field has multiple columns and a variable number of rows. I only want to validate the input of every second column of every row.

    Posted 7 years ago on Wednesday October 10, 2012 | Permalink
  4. OK, can you dump the complete $entry though and see what it contains? We have to at least have something in the array before we can process every other column in every row.

    Posted 7 years ago on Wednesday October 10, 2012 | Permalink
  5. http://pastie.org/5030007

    I want to validate the column: ticketnummer

    Posted 7 years ago on Wednesday October 10, 2012 | Permalink
  6. OK, it looks like that field has a value. This is the value of $field[6]?

    You said: "$list_values = unserialize($field[6]);' gives an empty array" but it appears this field, if this is field 6, actually contains serialized data? I can't figure out how unserialize would not return an array. If you print_r $list_values, it is empty?

    Posted 7 years ago on Wednesday October 10, 2012 | Permalink
  7. Allright it gives an array

    http://pastie.org/5030172

    That means the problem lies somewhere in the validation, I think i can make it work now.

    Thanks!

    Posted 7 years ago on Wednesday October 10, 2012 | Permalink
  8. I think you have it now. You just have to loop through the array and extra the columns you want from every row. Let us know if you need anything else.

    Posted 7 years ago on Wednesday October 10, 2012 | Permalink